catching a del

Dan Parisien dan at eevolved.com
Thu Mar 1 17:25:19 EST 2001


class obj:
        def __init__(self, name, parent):
                parent.children[name] = self
                self.parent = parent
                self.name = name

        def onDelete(self): #?!
                del self.parent[self.name]

I want to be able to catch a del of an instance of the above class so I can 
remove it from its parent dictionary. Is there a way? (note it cannot be in 
a destructor because there will always be a reference inside the parent 
dict)

Thanks,
Dan



More information about the Python-list mailing list