Dynamically change __del__

Lie Ryan lie.1296 at gmail.com
Fri Apr 30 21:39:24 CEST 2010

On 05/01/10 05:16, Nikolaus Rath wrote:
> Hi,
> I'm trying to be very clever:
> Apparently Python calls the class attribute __del__ rather than the
> instance's __del__ attribute. Is that a bug or a feature? Is there any
> way to implement the desired functionality without introducing an
> additional destroy_has_been_called attribute?
> (I know that invocation of __del__ is unreliable, this is just an
> additional safeguard to increase the likelihood of bugs to get noticed).

All Exception in __del__ is ignored for various reasons. It's safer if
you call destroy from inside __del__() so you cannot forget to remember
to call it manually.

def __del__(self):

More information about the Python-list mailing list