The folder a script is executed in
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Tue Aug 21 05:47:50 EDT 2007
Ant wrote:
> Do you mean the folder containing the script? Or the current
> working directory?
>
> If the former, then look at os.path.split(sys.argv[0])[0]
test.py:
| #!/usr/bin/env python
| import sys,os
| print os.path.split(sys.argv[0])[0]
$ cd tmp
~/tmp$ ../test.py
..
~/tmp$
That's rather not what's intended. I'd try os.path.abspath(__file__)
instead.
Regards,
Björn
--
BOFH excuse #113:
Root nameservers are out of sync
More information about the Python-list
mailing list