[Python-3000] Removing __del__

Giovanni Bajo rasky at develer.com
Sat Sep 23 11:13:41 CEST 2006


Aahz wrote:

>> Did you actually read my posts where I have shown some legitimate use
>> cases of __del__ which can't be substituted with short and elegant
>> enough code?
>
> The question is whether those use cases are frequent enough --
> especially for less-than-wizard programmers -- to warrant keeping
> __del__ around.

What I am basically against is the need of removing an easy syntax which can
have problematic side effects if you are not adult enough, in favor of a
complicated library workaround which requires deeper knowledge of Python
(weakrefs, lambdas, early binding of default arguments, just to name three),
and can cause side effects just as bad if you are not adult enough. Where's the
trade-off?

On the other hand, __close__ (out-of-order, recallable __del__) fixes some
issues of __del__, it is easy to teach and understand, it is easy to write.

And, if we could (optionally) raise a RuntimeError as soon an object with
__del__ enters a loop, would your opinion about it be different?

Giovanni Bajo



More information about the Python-3000 mailing list