What's the best way to iniatilize a function
Laurent Pointal
laurent.pointal at wanadoo.fr
Mon May 28 09:19:36 EDT 2007
Jack wrote:
>>> 2. what's the right way to call mylib_exit()? I put it in __del__(self)
>>> but it is not being called in my simple test.
>>
>> instance.__del__ is only called when there are no references to the
>> instance.
>
> I didn't call del explicitly. I'm expecting Python to call it when
> the program exits. I put a logging line in __del__() but I never
> see that line printed. It seems that __del__() is not being called
> even when the program exits. Any idea why?
If you make your extension available as a module (Python or C), you can use
atexit: http://docs.python.org/lib/module-atexit.html
Note: your exit handler will only be called at normal termination.
More information about the Python-list
mailing list