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.

Author abarnert
Recipients abarnert
Date 2014-01-14.04:27:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389673663.73.0.267088084088.issue20250@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-01-14 04:27:43abarnertsetrecipients: + abarnert
2014-01-14 04:27:43abarnertsetmessageid: <1389673663.73.0.267088084088.issue20250@psf.upfronthosting.co.za>
2014-01-14 04:27:43abarnertlinkissue20250 messages
2014-01-14 04:27:43abarnertcreate