catching a del

Werner Schiendl ws-news at gmx.at
Thu Mar 1 18:43:28 EST 2001


not sure how to implement such thing in python, but you could use an object
that has the reference to your object and allows the client software to
access the object's functionality
so you have references to the object in that 'reference' object and in the
dictionary
but only the client software has references to the 'reference' object (hate
that term, maybe someone more trained in english language can provide me
with a better one...)
so when all references to that new object are gone it will then be destroyed
and can remove the object from the dict

hth
werner

Dan Parisien <dan at eevolved.com> wrote in message
news:j%zn6.322252$f36.11513719 at news20.bellglobal.com...
> 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