program path

Peter Hansen peter at
Sun Jun 8 21:31:38 CEST 2003

Steven Taschuk wrote:
> Quoth Gerhard Häring:
>   [...sys.argv[0] test in WinXP...]
> > C:\>tmp\
> > C:\tmp\
> What happens if %PATH% includes c:\tmp, and you invoke it simply
> as '', from some other directory?

See Mike's reply... it works fine.

So basically os.path.abspath(sys.argv[0]) should be the idiomatic
way to find the full path where the __main__ script lives.

(I did try searching the archives for past discussions on this
but couldn't find a reference after a minute so I gave up.)


More information about the Python-list mailing list