How can a module find its own module object?

Michael Hudson mwh at python.net
Sun Dec 23 22:58:42 CET 2001


Oren Tirosh <oren-py-l at hishome.net> writes:

> 'import myname' is not exactly a reliable way to get your own module
> object - the file may be renamed, placed in a package, affected by
> case-sensitivity problems, loaded from somewhere not in the path, etc.
> 
> Is there any other way for a module to find itself other than searching 
> sys.modules for a module whose __dict__ is globals()?

What's wrong with __file__?

Cheers,
M.



More information about the Python-list mailing list