Python equivalent of C++'s virtual destructors?

Darrell Gallion darrell at dorb.com
Tue Aug 1 21:43:21 EDT 2000


From: <david_ullrich at my-deja.com>

>  "Note that it is possible (though not recommended!) for the
> __del__ method to postpone destruction of the instance by
> creating a new reference to it. It may then be called at a
> later time when this new reference is deleted. It is not
> guaranteed that __del__ methods are called for objects
> that still exist when the interpreter exits."
>
> The last sentence is news to me - it's not clear to me
> what a person _is_ supposed to do to guarantee things
> get cleaned up when the interpreter exits.
>


Maybe this will help.

<Cut from the manual >
sys.exitfunc
This value is not actually defined by the module, but can be set by the user
(or by a program) to specify a clean-up action at program exit. When set, it
should be a parameterless function. This function will be called when the
interpreter exits. Note: the exit function is not called when the program is
killed by a signal, when a Python fatal internal error is detected, or when
os._exit() is called.
</Cut from the manual >

--Darrell






More information about the Python-list mailing list