newb: object factory, and iteration
Jeremy Yallop
jeremy at jdyallop.freeserve.co.uk
Wed May 12 12:43:30 EDT 2004
Chris wrote:
> But is there a way for me to list all instances of a certain
> class?
I don't think there is, in general. If, as in your example, you can
modify the __init__ method of the class, you could add weak references
to created instances to a class member list. It would be even nicer,
though, to make a metaclass, instances of which maintain (weak)
references to instances of themselves.
Jeremy.
More information about the Python-list
mailing list