Customizing module globals

Kerim Borchaev ( WarKiD ) warkid at storm.ru
Fri Sep 7 14:55:40 EDT 2001


>> But te problem is that import fails...
>>
>>   File "ModuleUser.py", line 1, in ?
>>     import Module
>>   File "Module.py", line 1, in ?
>>     Object.doThings()
>>   NameError: name 'Object' is not defined
TR> OK, You can't modify a module until it has been imported successfully,
TR> and you cannot run something during import that has not yet been
TR> defined.  So module would have to import Object from somewhere else
TR> before it tries to access Object.

But there _is_ a module that isn't explicitly imported - __builtins__ .
And may be one can specify other names to be present in module's
namespace just before it is executed?

Best regards,
 Kerim                            mailto:warkid at storm.ru






More information about the Python-list mailing list