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 ExplodingCabbage
Recipients ExplodingCabbage
Date 2019-09-29.16:12:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569773559.86.0.293665151535.issue38315@roundup.psfhosted.org>
In-reply-to
Content
There seems to be at least some demand for the ability to have the key being accessed be passed to the factory function of a defaultdict. See e.g. https://stackoverflow.com/q/2912231/1709587 (13k views) or previous enhancement suggestion https://bugs.python.org/issue30408.

However, as noted on that issue, defaultdict cannot simply be modified to pass the key to the factory function without breaking backwards compatibility.

Perhaps it makes sense, then, to have a separate class in the collections module, perhaps called keydefaultdict, that is like defaultdict but whose factory function receives one argument, which is the key being accessed? Having this built into the standard library would be slightly more convenient than either making an ad-hoc dict subclass every time this functionality is needed or having to roll your own subclass like the one at https://stackoverflow.com/a/2912455/1709587.
History
Date User Action Args
2019-09-29 16:12:39ExplodingCabbagesetrecipients: + ExplodingCabbage
2019-09-29 16:12:39ExplodingCabbagesetmessageid: <1569773559.86.0.293665151535.issue38315@roundup.psfhosted.org>
2019-09-29 16:12:39ExplodingCabbagelinkissue38315 messages
2019-09-29 16:12:39ExplodingCabbagecreate