Advice needed on __del__

Fredrik Lundh fredrik at pythonware.com
Mon May 9 15:02:39 EDT 2005


André Roberge wrote:


> This morning I had the following thought:
> I can, when I create a Jekyll object, update
> an outside_list.
> If, somehow, I could update that list when
> a Jekyll object disappears
> (perhaps by using __del__, which I have never touched)

Python makes no guarantees whatsover about when and how to
run __del__, so relying on it to remove user-visible resources is a
rather bad idea.

> Any suggestions?

why wouldn't

    def subplot():
         Evil = Jekyll()   # Evil_twin gets created and displayed
         Evil.doStuff()    # Evil_twin does stuff on the screen
         Evil.destroy()

work for you?

</F>






More information about the Python-list mailing list