Re: sys.modules and __main__ obscureness

2006-07-16 Thread K.S.Sreeram
Fuzzyman wrote: > That was a quick response. :-) > > Thanks very much. Sigh.. When I'm drowning in arcane win32 c++ crap, I tend to jump on anything interesting on python-list. It feels like a breath of fresh air! [sreeram;] signature.asc Description: OpenPGP digital signature -- http://mail

Re: sys.modules and __main__ obscureness

2006-07-16 Thread Fuzzyman
K.S.Sreeram wrote: > 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 > t

Re: sys.modules and __main__ obscureness

2006-07-16 Thread K.S.Sreeram
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 d

sys.modules and __main__ obscureness

2006-07-16 Thread Fuzzyman
Hello all, I am messing with namespaces, so that code I exec thinks it is executing in the __main__ module. I have the following code : import imp import sys # can't call the module '__main__' or 'new_module' returns the real one module = imp.new_module('_') namespace = module.__dict__ namespac