Empty sys.path[0]

Peter Hansen peter at engcorp.com
Mon Jul 9 03:34:01 EDT 2001


Gustaf Liljegren wrote:
> That works. Now I run it from the same directory, but still with the full
> path:
> 
> E:\test>python e:\test\syspath.py
> e:\test
> 
> That works too, but look here when I run it with only the filename:
> 
> E:\test>python syspath.py
> 
> Nothing! This is the problem I have. It think the second and third case
> ought to mean the same.

By now you should have seen my other post from Saturday which shows
how to use os.path.abspath(), which converts relative paths to absolute
ones by prepending os.getcwd() when required.

sys.path[0] should perhaps show an absolute path, but there are probably
arguments for why it should not, too.  Just convert to an abspath and
your troubles will be gone. :)

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list