to ask an container instance to suicide
jm.suresh@no.spam.gmail.com
jm.suresh at gmail.com
Mon Nov 20 04:42:22 EST 2006
Hi,
I have containers to hold geometrical objects. The members in these
containers can again be containers them self. Now, In the program I
would be moving objects from one container to another. In this process,
If the number of members in one of the containers becomes just one, I
want to delete that container and have only its only member in place of
it in the parent container.
I have implemented setting and getting the container members using
property().
Right now, I am planning to do this this way:
Maintain a reference to parent container in each container.
When the condition is detected, do self.parent.deleteObject(self) .
def deleteObject(self,memberId):
index = self._members.index(memberId)
self._members[index] = memberId._members[0]
del memberId
Will this work. Or is there any other simple way to do this?
--
Suresh
More information about the Python-list
mailing list