Destructor Woes, was Advice needed on __del__

Fredrik Lundh fredrik at pythonware.com
Thu May 12 06:45:36 EDT 2005


"phil" <phillip.watts at anvilcom.com> wrote:

>> Then i got a tip that you can register a function that needs to be
>> called when the object is going to be deleted.
>> For instance to register a function __exit, you do this:
>
> Here is the complete line class with your suggestion:
>
> Below is the output.
>
> Nice idea, maybe I did something wrong?
>
> class line:
> def __init__(s,glob,argl,color=''):
>     atexit.register(s.__exit)

atexit is used to clean up when the *interpreter* shuts down, not when
any object is going to be deleted.

>   File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 2085, in delete
>     self.tk.call((self._w, 'delete') + args)
> _tkinter.TclError: invalid command name ".1076354284"

this usually means that you're trying to execute Tkinter methods on a
widget that no longer exists (probably because Tkinter has been shut
down, at this point).

</F> 






More information about the Python-list mailing list