bytecolor <[EMAIL PROTECTED]> wrote: > Thanks Alex, the weak references *seem* to be doing what I want for > now. > > In each __init__() I use: > aptbase.drawables.append(weakref.ref(self)) > > Then in show(): > for d in aptbase.drawables: > o = d() > if o is not None: > # render it
Looks good, so apparently you didn't particularly care about assignment to variables vs assignment to other "labels" -- great! My favourite way to use weakref is slightly different: I would have aptbase.drawables = weakref.WeakValueDictionary then in each __init__ aptbase.drawables[len(aptbase.drawables)] = self then in show: for o in aptbase.drawables.values(): # render it Not a vastly different idiom from yours, mind you, but I like not having to check whether an object has gone away -- a WeakValueDictionary's entries just disappear when the value object goes away, so that at any time looping on its .values() is safe as brick houses!-) Alex -- http://mail.python.org/mailman/listinfo/python-list