The folder a script is executed in

Ant antroy at gmail.com
Tue Aug 21 06:12:50 EDT 2007


On Aug 21, 10:47 am, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> Ant wrote:
...
> | 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.

Fair point. On Win32 sys.argv[0] always seems to give the full path
rather than the relative path - hadn't realised it was different for
linux (?).

--
Ant...

http://antroy.blogspot.com/





More information about the Python-list mailing list