How to get current module object

Alex noname9968 at gmail.com
Sun Feb 17 13:25:44 EST 2008


Can I get reference to module object of current module (from which the 
code is currently executed)? I know __import__('filename') should 
probably do that, but the call contains redundant information (filename, 
which needs to be updated), and it'll perform unnecessary search in 
loaded modules list.

It shouldn't be a real problem (filename can probably be extracted from 
the traceback anyway), but I wonder if there is more direct and less 
verbose way.

Thanks



More information about the Python-list mailing list