Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print __file__ without file extension

Tags:

python

Is there a better way to print __file__ without the extension?

import os
print os.path.splitext(__file__)[0]
like image 761
Ethan Whitt Avatar asked Oct 22 '25 15:10

Ethan Whitt


1 Answers

You can use string.split, but what's the point? The standard library is giving you the exact tool you need.

like image 101
Adam Matan Avatar answered Oct 25 '25 07:10

Adam Matan