Determine path of current module?

Jürgen Hermann jhe at webde-ag.de
Thu Jul 20 04:02:10 EDT 2000


"Carsten Gaebler" <cg at schlund.de> schrieb im Newsbeitrag
news:3976AA30.1C4F62B8 at schlund.de...
> How can I determine the path of the current module at runtime?
(sys.argv[0]
> won't work when running it through pythondoc)

### mypath.py
import sys
print sys.modules[__name__].__file__


[d:\tmp]python -c "import mypath"
mypath.py

[d:\tmp]python -c "import mypath"
mypath.pyc


Ciao, Jürgen





More information about the Python-list mailing list