sys.argv[0] - Returns path and filename.

Paul Moore gustav at
Thu Jun 27 15:29:08 CEST 2002

"Mark McEahern" <marklists at> writes:

>> How do I get the current path of the script I am running, on the mac
>> osx and the linux box ? (Any work around would be great, I don't want
>> to have to hardcode the path into the script, or even give the path as
>> an argument,I want the script to know where it is.)
> import os
> print os.getcwd()

Or os.path.abspath(sys.argv[0]).

Run this before you change directory...


More information about the Python-list mailing list