Get all the instances of one class

Matt Nordhoff mnordhoff at mattnordhoff.com
Sun May 18 23:55:17 EDT 2008


Tommy Nordgren wrote:
> class MyClass : a_base_class
>       memberlist=[]
> 
> #  Insert object in memberlist when created;
> #  note: objects won't be garbage collected until removed from memberlist.

Just to say, if you wanted to go about it that way, you could avoid the
garbage collection problem by using weakrefs:

<http://docs.python.org/lib/module-weakref.html>
-- 



More information about the Python-list mailing list