[python-win32] smart : __del__ replace atexit

Mark Hammond mhammond at skippinet.com.au
Tue Aug 22 09:08:33 CEST 2006


> A little stunt :  in COM server (with pywin32), atexit is not
> interesting.

Yeah, Python is never 'finalized' when it is loaded for use by a COM object.

> Then, look, in the class-serverCOM, the method   __del__(self):
> When you close the COM-server, or when you exit the
> application who called
> the COM-server, the method is called.

This should be reliable - assuming that the program *using* the COM object
always destroys the COM object correctly.  However, it would be possible to
write a Python program that used the COM object that did *not* cleanup the
object, so would not cause this method to be executed...

Mark



More information about the Python-win32 mailing list