sys.argv[0] doesn't always contain the full path of running script.

gmax2006 mapsetah2000-maillist5 at yahoo.ca
Tue Aug 29 13:37:17 EDT 2006


Hi,

I use RedHat linux.

How can I find where exactly the current python script is running?

I use this code:

#test.py
import os,sys
print sys.argv
os.chdir(os.path.dirname(sys.argv[0]))


It doesn't work when I run this command from the directory that
test.py is located:

python test.py

That means sys.argv[0] doesn't always contain the full path of
running script.

Any help would be appreciated,
Max




More information about the Python-list mailing list