self for modules
Terry Reedy
tjreedy at udel.edu
Fri Mar 5 09:38:38 EST 2004
"Bertram Scharpf" <b.scharpf at tesionmail.de> wrote in message
news:slrnc4gvn4.md9.b.scharpf at homer.bertram-scharpf...
> Hi,
>
> when I want to access the module itself, I can write
>
> ----
> import sys
> module_self = sys.modules[ __name__]
> ----
>
> Is there a smarter way to do this?
shorter and not implementation specific is
>>> mymod = __import__(__name__)
>>> mymod
<module '__main__' (built-in)>
I presume this works in imported module also.
Terry J. Reedy
More information about the Python-list
mailing list