How to delete yourself????
Kay Schluehr
kay.schluehr at gmx.net
Fri Oct 14 10:45:05 EDT 2005
christian.siegl at gmail.com wrote:
> Hello,
>
>
> I got a problem deleting objects, which are placed in a hirarchy....
>
> Asume we have the following code:
> ########################################################
> class parent:
>
> MyChilds = [] # this list is filled with childs....
>
> def AddChild(self, child):
> # add childs here, however this is done, it's not the point...
> child.MyParent = self
>
> def RemoveChild(self, child):
> # delete child from the list.... the way this is done is not
> our
> # problem here
>
>
> class child:
>
> MyParent = 0
>
> def deleteMe(self):
> MyParent.RemoveChild(self)
> ##############################################################
Please help me understand the child class. It does not make much sense
to me at all.
Why is it not sufficient to call child.parent.remove(child) if the
caller holds a child object but not the parent? Otherwise it should be
sufficient to call parent.remove(child).
Kay
More information about the Python-list
mailing list