default behavior

Wolfram Hinderer wolfram.hinderer at googlemail.com
Fri Aug 6 18:24:21 EDT 2010


On 6 Aug., 22:07, John Posner <jjpos... at optimum.net> wrote:
> On 8/2/2010 11:00 PM, John Posner wrote:
>
> > On 7/31/2010 1:31 PM, John Posner wrote:
>
> >> Caveat -- there's another description of defaultdict here:
>
> >>http://docs.python.org/library/collections.html#collections.defaultdict
>
> >> ... and it's bogus. This other description claims that __missing__ is a
> >> method of defaultdict, not of dict.
>
> > Following is a possible replacement for the bogus description. Comments
> > welcome. I intend to submit a Python doc bug, and I'd like to have a
> > clean alternative to propose.
>
> After some off-list discussion with Ethan Furman (many thanks!), the
> Python Doc bug is submitted: #9536 at bugs.python.org.
>
> -John

This is probably nitpicking, but the patch calls __missing__ a special
method. However, unlike special methods, it is not invoked by "special
syntax" but by the dict's __getitem__ method. (len() invokes __len__
on any object - you can't do something similar with __missing__.)

__missing__ is also not listed as a special method on
http://docs.python.org/py3k/reference/datamodel.html#special-method-names

However, "normal" special method lookup seems to be used.



More information about the Python-list mailing list