Rhamphoryncus wrote:
class RealFoo:
refs = set()
def __init__(self, front):
self.refs.add(weakref.ref(front, self.cleanup))
def blah(self):
print "Blah!"
def cleanup(self, ref):
print "Doing cleanup"
self.refs.remove(ref)
That won't work, because the bound method you're usin
I know __del__ can't be relied on to do cleanup, so I'm thinking of
using a globally reachable weakref to do the job, like so:
import weakref
class Foo:
def __init__(self, *args, **kwargs):
self.__realfoo = RealFoo(self, *args, **kwargs)
def blah(self):
return self.__realfoo.blah()
c