[issue40248] Proposed class for collections: dynamicdict

Steven D'Aprano report at bugs.python.org
Fri Apr 10 21:30:21 EDT 2020


Steven D'Aprano <steve+python at pearwood.info> added the comment:

This feature is already provided by just supplying a `__missing__` dunder:

py> class MyDict(dict):
...     def __missing__(self, key):
...             return "The key is {}".format(key)
...
py> d = MyDict()
py> d[1234]
'The key is 1234'


I'm closing this ticket, but if the discussion on Python-Ideas reaches consensus that your class is necessary, feel free to re-open it.

----------
nosy: +steven.daprano
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40248>
_______________________________________


More information about the Python-bugs-list mailing list