How to refer to the current module?

Christian Heimes lists at cheimes.de
Mon Jan 7 09:48:00 EST 2008


Mike wrote:
> Is there any way around this?  Can I somehow scope the 'current
> module' and give getattr(...) an object that will (at run time) have
> the appropriate bindings?

globals() for the current name space

import sys
sys.modules[__name__] gets you the module object

Christian




More information about the Python-list mailing list