Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1ae570

Browse files
authored
bpo-41621: Document defaultdict's default_factory parameter (GH-21945)
It defaults to None and is positional only.
1 parent adfa1ba commit d1ae570

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

Doc/library/collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,9 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
707707
:class:`defaultdict` objects
708708
----------------------------
709709

710-
.. class:: defaultdict([default_factory[, ...]])
710+
.. class:: defaultdict(default_factory=None, /, [...])
711711

712-
Returns a new dictionary-like object. :class:`defaultdict` is a subclass of the
712+
Return a new dictionary-like object. :class:`defaultdict` is a subclass of the
713713
built-in :class:`dict` class. It overrides one method and adds one writable
714714
instance variable. The remaining functionality is the same as for the
715715
:class:`dict` class and is not documented here.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document that :class:`collections.defaultdict` parameter ``default_factory`` defaults to None and is positional-only.

Modules/_collectionsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ defdict_init(PyObject *self, PyObject *args, PyObject *kwds)
22412241
}
22422242

22432243
PyDoc_STRVAR(defdict_doc,
2244-
"defaultdict(default_factory[, ...]) --> dict with default factory\n\
2244+
"defaultdict(default_factory=None, /, [...]) --> dict with default factory\n\
22452245
\n\
22462246
The default factory is called without arguments to produce\n\
22472247
a new value when a key is not present, in __getitem__ only.\n\

0 commit comments

Comments
 (0)