On Wed, 23 Dec 2009 15:18:10 -0800, Carl Banks wrote:

>> > # will unload mod1 assuming mod1 was the only reference to that
>> > module.
>>
>> Which is highly unlikely. Any classes or functions from the module will
>> keep the module alive.
> 
> Actually, they won't.  Neither classes nor functions directly reference
> their module; classes know their module only by name, and functions only
> hold references to the module's namespace, not to the module itself.  So
> if any references to functions defined in the module remain, the module
> dict will stick around, but the module itself may be collected.

Hmmm... so it seems. Well spotted, thanks.

It makes sense to do it that way, as it prevents circular references 
(module contains a class which contains the module which...).



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

Reply via email to