Dynamically change __del__

Jerry Hill malaclypse2 at gmail.com
Fri Apr 30 15:43:08 EDT 2010


On Fri, Apr 30, 2010 at 3:16 PM, Nikolaus Rath <Nikolaus at rath.org> wrote:
> 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?

It's a documented feature:
http://docs.python.org/reference/datamodel.html#new-style-special-lookup

I'm not aware of a way to get around it, so I think you'll need to
fall back to checking a flag in the class's __del__ method.

-- 
Jerry



More information about the Python-list mailing list