Generator inside a class prevent __del__ ??

Joe Mason joe at notcharles.ca
Wed Apr 21 20:15:26 EDT 2004


In article <40866ECD.A45758B9 at free.fr>, Emmanuel wrote:
> Thank you very much for your answer, but I'm still not sure I understand it.
> If I understand your words right, creating self.Coroutine as an iterator on
> the generator function will create a reference on self, so if I want to use a
> generator in a class ( and I really want to ), I must delete explicitly the
> iterator before I destroy the object.
> 
> Trouble is, I _would_ like not to care about the lifetime of the object, and I
> don't know where it will be destroyed.

Try looking up "weakref".  (I've never used them myself, so I don't know
the exact syntax.)

Joe



More information about the Python-list mailing list