This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: defaultdict docstring neglects the *args
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: abarnert, python-dev
Priority: normal Keywords: patch

Created on 2014-01-14 04:27 by abarnert, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
collectionsmodule.diff abarnert, 2014-01-14 04:27 add [, ...] and copy the sentence about additional args from docs review
Messages (2)
msg208071 - (view) Author: Andrew Barnert (abarnert) * Date: 2014-01-14 04:27
The docstring for defaultdict shows only a single argument, default_factory, and gives no clue that you can pass additional arguments:

    |  defaultdict(default_factory) --> dict with default factory
    |
    |  The default factory is called without arguments to produce
    |  a new value when a key is not present, in __getitem__ only.
    |  A defaultdict compares equal to a dict with the same items.

The docs, by contrast, say:

> class collections.defaultdict([default_factory[, ...]])

> … The first argument provides the initial value for the default_factory attribute; it defaults to None. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.

I think the docstring should have the same information—or at least have the correct signature, which would hopefully be enough to prompt people to look at the docs.

I'm not sure whether the correct signature is (default_factory, *args, **kwargs), like OrderedDict, or (default_factory[, ...]), like deque, but I don't think either one would confuse anyone.
msg208072 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-01-14 04:56
New changeset d46bf7835b45 by Benjamin Peterson in branch '3.3':
correct defaultdict signature in docstring (closes #20250)
http://hg.python.org/cpython/rev/d46bf7835b45

New changeset 950f1e83bb56 by Benjamin Peterson in branch '2.7':
correct defaultdict signature in docstring (closes #20250)
http://hg.python.org/cpython/rev/950f1e83bb56

New changeset 49ae53150ee0 by Benjamin Peterson in branch 'default':
merge 3.3 (#20250)
http://hg.python.org/cpython/rev/49ae53150ee0
History
Date User Action Args
2022-04-11 14:57:56adminsetgithub: 64449
2014-01-14 04:56:42python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg208072

resolution: fixed
stage: resolved
2014-01-14 04:27:43abarnertcreate