catching a del
Gregory Jorgensen
gregj at pobox.com
Thu Mar 1 19:18:05 EST 2001
Add a delete method to the parent class; that seems the most direct solution.
Unlike "delete" in C++, Python's "del" statement doesn't delete an object, it
decrements the object's reference count and removes the deleted name.
In article <j%zn6.322252$f36.11513719 at news20.bellglobal.com>, Dan Parisien
says...
>
>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)
Greg Jorgensen
Deschooling Society
Portland, Oregon, USA
gregj at pobox.com
More information about the Python-list
mailing list