Empty sys.path[0]
Peter Hansen
peter at engcorp.com
Sat Jul 7 11:59:54 EDT 2001
Michal Wallace wrote:
>
> On 7 Jul 2001, Gustaf Liljegren wrote:
>
> > The problem is that I can't find a way to get this directory. The
> > docs say that sys.path[0] should be used for this, but that does
> > only return an empty string.
>
> Where do the docs say this? It sounds like a mistake, or something
> that needs clarification..
>
> you want os.getcwd()
It's more likely he wants something with sys.argv[0]. He
wanted the directory of the Python script, which might not be the
same as os.getcwd().
import sys, os
x = os.path.abspath(sys.argv[0])
--
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com
More information about the Python-list
mailing list