New submission from Andrew Barnert: 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. ---------- components: Library (Lib) files: collectionsmodule.diff keywords: patch messages: 208071 nosy: abarnert priority: normal severity: normal status: open title: defaultdict docstring neglects the *args type: enhancement Added file: http://bugs.python.org/file33456/collectionsmodule.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20250> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com