Destructor Woes, was Advice needed on __del__

flupke flupke at nonexistingdomain.com
Thu May 12 09:12:59 EDT 2005


Fredrik Lundh wrote:
> "flupke" 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:
> 
> 
>>>class line:
>>>    def __init__(s,glob,argl,color=''):
>>>        atexit.register(s.__exit)
> 
> 
>>I don't know what's wrong in your example. Here it works (doesn't help
>>you of course). I would first try with an easy example an try to test
>>the atexit functionality like that. It seems that the problem you are
>>having isn't related to the atexit part.
> 
> 
> do you (or whoever gave you the tip) have the slightest idea what atexit does?
> 
> </F> 

As i said, it works for me. I use it to log the closure of my main 
program. Maybe my first message wasn't clear on the use of atexit.

Benedict



More information about the Python-list mailing list