How to access a module's namespace within the module at import

Rowland Smith rowland at webperformanceinc.com
Tue Jan 15 16:57:43 EST 2002


I have a module that has a number of classes defined.  In the module 
initialization code I want to look at the __dict__ of the module and 
examine the classes that have been defined.

Using sys.modules[ 'module_name' ] doesn't work because the module 
import has not finished when the code that looks at sys.modules runs.

The cleanest solution is to examine the module from another module, but 
due to the current design and recursive imports it gets ugly.

Thanks,
Rowland




More information about the Python-list mailing list