getting "this" module's path
Neal Norwitz
neal at metaslash.com
Fri Jan 4 15:06:47 EST 2002
"Clark C . Evans" wrote:
>
> How do I get the path name for a module (in particular,
> the module that is currently executing?).
I believe what you are asking for is:
import sys
this_module = sys.modules[__name__]
print this_module.__file__
Although when I tried this when __name__ == '__main__' and
it didn't seem to work. It should for other modules imported.
Neal
More information about the Python-list
mailing list