Unimport module
Chmouel Boudjnah
cboudjnah at squiz.net
Mon Mar 14 00:49:30 EST 2005
Terry Reedy wrote:
> Yes, Python's import mechanism assumes that sys.path is relatively static,
> or grow only. I not sure what 'reload Module' would do after the first
> loop.
it does work using like that :
if sys.modules.has_key("Module"):
reload(Module)
else:
import Module
i think it's kind of cleaner solution.
>>which after it does works fine. But my question is what's happenning in
>>the internals, does it free the memory of Module to do a sys.modules.pop
> A Python implementation *may* 'free' an object anytime after the last
> reference to the object disappears. Whether the name Module and the slot
> in sys.modules are the only two references depends, I believe, on both the
> code in the module and the code the uses it. sys.getrefcount() can help
> answer this.
ah ok, thanks to make this thing clear, do you have any pointer how to
debug/watch the python internals ?
Cheers, Chmouel.
--
Chmouel Boudjnah -- Squiz.net -- http://www.squiz.net/
More information about the Python-list
mailing list