Re: Iterating over objects of a class

2008-12-24 Thread Scott David Daniels
Kottiyath wrote: ... Having a registry inside the class instance and looping through them was the only clean thing I could think of. I understand that garbage collection would be an issue - but is there any way out? Search for weakref in the documentatione. In this case, I'd use a WeakValueDict

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 11:48 pm, "Gabriel Genellina" wrote: > En Wed, 24 Dec 2008 16:18:55 -0200, Kottiyath   > escribió: > > >> The other thing to remember is that because the 'registry' contains > >> references to the instances, they won't be garbage collected. > > > Is there any other way out in this case

Re: Iterating over objects of a class

2008-12-24 Thread Gabriel Genellina
En Wed, 24 Dec 2008 16:18:55 -0200, Kottiyath escribió: The other thing to remember is that because the 'registry' contains references to the instances, they won't be garbage collected. Is there any other way out in this case? I have factory methods - and I have to loop over them - sort of

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 11:04 pm, MRAB wrote: > Diez B. Roggisch wrote: > > Kottiyath schrieb: > >> Hi, > >>    How can I iterate over all the objects of a class? > >>    I wrote the code like following: > >> class baseClass(object): > > > Consider adopting PEP 8  coding conventions. > > >>     __registry = []

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 10:52 pm, "Diez B. Roggisch" wrote: > Kottiyath schrieb: > > > Hi, > >    How can I iterate over all the objects of a class? > >    I wrote the code like following: > > class baseClass(object): > > Consider adopting PEP 8  coding conventions. > > > > >     __registry = [] > > >     def

Re: Iterating over objects of a class

2008-12-24 Thread MRAB
Diez B. Roggisch wrote: Kottiyath schrieb: Hi, How can I iterate over all the objects of a class? I wrote the code like following: class baseClass(object): Consider adopting PEP 8 coding conventions. __registry = [] def __init__(self, name): self.__registry.append(se

Re: Iterating over objects of a class

2008-12-24 Thread Diez B. Roggisch
Kottiyath schrieb: Hi, How can I iterate over all the objects of a class? I wrote the code like following: class baseClass(object): Consider adopting PEP 8 coding conventions. __registry = [] def __init__(self, name): self.__registry.append(self) self.name = n

Iterating over objects of a class

2008-12-24 Thread Kottiyath
Hi, How can I iterate over all the objects of a class? I wrote the code like following: class baseClass(object): __registry = [] def __init__(self, name): self.__registry.append(self) self.name = name def __iter__(self): baseClass.item = 0 return