@@ -3761,11 +3761,13 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
37613761 Return the item of *d * with key *key *. Raises a :exc: `KeyError ` if *key * is
37623762 not in the map.
37633763
3764- If a subclass of dict defines a method :meth: `__missing__ `, if the key *key *
3764+ .. index :: __missing__()
3765+
3766+ If a subclass of dict defines a method :meth: `__missing__ ` and *key *
37653767 is not present, the ``d[key] `` operation calls that method with the key *key *
37663768 as argument. The ``d[key] `` operation then returns or raises whatever is
3767- returned or raised by the ``__missing__(key) `` call if the key is not
3768- present. No other operations or methods invoke :meth: `__missing__ `. If
3769+ returned or raised by the ``__missing__(key) `` call.
3770+ No other operations or methods invoke :meth: `__missing__ `. If
37693771 :meth: `__missing__ ` is not defined, :exc: `KeyError ` is raised.
37703772 :meth: `__missing__ ` must be a method; it cannot be an instance variable::
37713773
@@ -3779,8 +3781,9 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
37793781 >>> c['red']
37803782 1
37813783
3782- See :class: `collections.Counter ` for a complete implementation including
3783- other methods helpful for accumulating and managing tallies.
3784+ The example above shows part of the implementation of
3785+ :class: `collections.Counter `. A different ``__missing__ `` method is used
3786+ by :class: `collections.defaultdict `.
37843787
37853788 .. describe :: d[key] = value
37863789
0 commit comments