@@ -741,14 +741,18 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
741741 defaultdict(default_factory, iterable, /, **kwargs)
742742
743743 Return a new dictionary-like object. :class: `defaultdict ` is a subclass of the
744- built-in :class: `dict ` class. It overrides one method and adds one writable
745- instance variable. The remaining functionality is the same as for the
746- :class: `dict ` class and is not documented here.
744+ built-in :class: `dict ` class. If :attr: `default_factory ` is not ``None ``, a
745+ missing key causes the factory to be called without arguments; its result is
746+ inserted into the dictionary and returned. If :attr: `default_factory ` is
747+ ``None ``, missing-key access raises a :exc: `KeyError ` exception. The remaining
748+ functionality is the same as for the :class: `dict ` class and is not documented
749+ here.
747750
748751 The first argument provides the initial value for the :attr: `default_factory `
749- attribute; it defaults to ``None ``. All remaining arguments are treated the same
750- as if they were passed to the :class: `dict ` constructor, including keyword
751- arguments.
752+ attribute; it should be a callable or ``None ``. If it is neither, a
753+ :exc: `TypeError ` exception is raised. It defaults to ``None ``. All remaining
754+ arguments are treated the same as if they were passed to the :class: `dict `
755+ constructor, including keyword arguments.
752756
753757 :class: `!defaultdict `\s are :ref: `generic <generics >` over two types,
754758 signifying (respectively) the types of the dictionary's keys and values.
0 commit comments