get directory name of file being executed
Bernhard Herzog
bh at intevation.de
Thu Feb 27 12:28:08 EST 2003
Skip Montanaro <skip at pobox.com> writes:
> David> I'm doing this:
>
> David> /usr/bin/python2 /some/script/in/a/dir/foo.py
>
> David> I want to get "/some/script/in/a/dir/", not the cwd of where I
> David> launched the script from.
[...]
>
> Inside foo.py you have a global variable __file__.
Not with Python 2.2.x, unfortunately. This will work with 2.3, though.
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://www.mapit.de/
More information about the Python-list
mailing list