[Python-checkins] bpo-41621: Document defaultdict's default_factory parameter (GH-21945)
terryjreedy
webhook-mailer at python.org
Wed Jun 23 10:58:41 EDT 2021
https://github.com/python/cpython/commit/88a3342314c8b9ff40a2b6fd4759cfbf64712c67
commit: 88a3342314c8b9ff40a2b6fd4759cfbf64712c67
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: terryjreedy <tjreedy at udel.edu>
date: 2021-06-23T10:58:20-04:00
summary:
bpo-41621: Document defaultdict's default_factory parameter (GH-21945)
It defaults to None and is positional only.
(cherry picked from commit d1ae57027fc39ff60dcfc1b63881400e5ca3ce56)
Co-authored-by: Dennis Sweeney <36520290+sweeneyde at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Documentation/2020-08-24-13-35-04.bpo-41621.nqaw9G.rst
M Doc/library/collections.rst
M Modules/_collectionsmodule.c
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 94166ec6c754a..a63090414d439 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -707,9 +707,9 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
:class:`defaultdict` objects
----------------------------
-.. class:: defaultdict([default_factory[, ...]])
+.. class:: defaultdict(default_factory=None, /, [...])
- Returns a new dictionary-like object. :class:`defaultdict` is a subclass of the
+ Return a new dictionary-like object. :class:`defaultdict` is a subclass of the
built-in :class:`dict` class. It overrides one method and adds one writable
instance variable. The remaining functionality is the same as for the
:class:`dict` class and is not documented here.
diff --git a/Misc/NEWS.d/next/Documentation/2020-08-24-13-35-04.bpo-41621.nqaw9G.rst b/Misc/NEWS.d/next/Documentation/2020-08-24-13-35-04.bpo-41621.nqaw9G.rst
new file mode 100644
index 0000000000000..bd193d9163073
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2020-08-24-13-35-04.bpo-41621.nqaw9G.rst
@@ -0,0 +1 @@
+Document that :class:`collections.defaultdict` parameter ``default_factory`` defaults to None and is positional-only.
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 9c8701af904ab..eff03c789ede6 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -2236,7 +2236,7 @@ defdict_init(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(defdict_doc,
-"defaultdict(default_factory[, ...]) --> dict with default factory\n\
+"defaultdict(default_factory=None, /, [...]) --> dict with default factory\n\
\n\
The default factory is called without arguments to produce\n\
a new value when a key is not present, in __getitem__ only.\n\
More information about the Python-checkins
mailing list