__file__ with pythonw

Vidar Gundersen vbg-news at bitjungle.com
Mon Feb 12 05:31:37 EST 2001


how can i get a string with the path to
the current python script?
(should work both with .py and .pyw)


problem using __file__:
the statement below works as expected with python.exe,
but fails with pythonw.exe because:
-- variable __file__ does not exist (?)
-- sys.path[0] is empty
how come? is it a bug? system info: python 2.0, windows 95

try: filepath = os.path.split(__file__)[0]
except: filepath = sys.path[0]


-- 
Vidar Bronken Gundersen



More information about the Python-list mailing list