Entry
How can I get my _full_ program name (eg. "mylongpythonscript.py") under eg. NT? sys.argv[0] gives me the truncated MS-DOS style, "MYLONG~1.PY" etc.
Oct 11th, 2000 06:48
Jon Nicoll, unknown unknown, Alex Martelli
This seems to work in my setup (2.0b2, Win98):
import sys
try: raise RuntimeError
except:
x=sys.exc_info()[2]
print x.tb_frame.f_code.co_filename
Placing this in alongfilename.py and running
python alongfilename.py
results in the expected output:
alongfilename.py
##################################################
# Under (NT4, Python v1.5.2), the above also gives
# the 'short' form for me.
# This is a bit more Win32 specific, but works for my environment
import sys
import win32api
print win32api.FindFiles(sys.argv[0])[0][8]