self destruction :)
gerhard.haering at gmx.de
Thu Jun 27 16:10:00 EDT 2002
Am Thu, 27 Jun 2002 19:54:51 GMT schrieben Sie (Guyon Morée <gumuz at looze.net>):
> i've got a list of dynamicaly instantiated objects of a class of my own.
> can i let one of the objects delete itself?
> i've tried: 'del self', but somehow it didn't work. afterwards it should
> also _not_ be in the list anymore.
This might work for you:
Mark the object as closed by setting self.closed to 1. Then, periodically,
scan your objects, and delete any that have closed == 1. You cannot if any
of the objects's methods are still in the call stack. What I mean, you can
not call the cleanup function from within any of the object's methods.
I have no idea what you're trying to do, but if you want to make some sort
of simulation, either multithreading or a state machine that's run from a
main loop doing the cleanup should work.
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list