Python equivalent of C++'s virtual destructors?

Alex Martelli alex at magenta.com
Tue Aug 1 17:51:49 EDT 2000


<david_ullrich at my-deja.com> wrote in message
news:8m6v04$2q1$1 at nnrp1.deja.com...
    [snip]
>  "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.

Calling delete on all global variables should do it, if
it's so crucial, unless of course there are cycles...

Personally, I rely on the operating system cleaning up
after me as soon as my process is over.  Lazy, but...


Alex






More information about the Python-list mailing list