Fuzzyman wrote:
> This code behaves differently when entered into an interactive
> interpreter session. When run as a program you will see that module and
> namespace have both become None !!

Thats because the reference count to the current '__main__' module goes
to 0, and the module object gets deleted along with its globals 'module'
and 'namespace'. The code keeps working because the codeobject is
retained by the interpreter.

To make it work, simply retain a reference to the existing module,
before overwriting with the new module.

sys.blahblah = sys.modules['__main__']
sys.modules['__main__'] = module

[sreeram;]

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to