__delitem__ "feature"

Ian Kelly ian.g.kelly at gmail.com
Mon Dec 27 19:41:07 EST 2010


On 12/26/2010 11:49 AM, kj wrote:
> In<mailman.302.1293387041.6505.python-list at python.org>  Ian Kelly<ian.g.kelly at gmail.com>  writes:
>
>> On 12/26/2010 10:53 AM, kj wrote:
>>> P.S. If you uncomment the commented-out line, and comment out the
>>> last line of the __init__ method (which installs self._delitem as
>>> self.__delitem__) then *all* the deletion attempts invoke the
>>> __delitem__ method, and are therefore blocked.  FWIW.
>
>> Because subclasses of builtins only check the class __dict__ for special
>> method overrides, not the instance __dict__.
>
>
> How do you know this?

 From memory, although it seems I remembered it slightly wrong; it's the 
way new-style classes work in general, not anything to do with builtins 
in particular.

> Is this documented?

Yes, as others have pointed out.

> Or is this a case of Monday-night quarterbacking?

Do you mean "Monday-morning quarterbacking"?  Either way, I don't know 
what you mean by that in this context.




More information about the Python-list mailing list