Sujet : Re: How would you name this dictionary?
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 22. Jan 2024, 08:16:51
Autres entêtes
Organisation : Stefan Ram
Message-ID : <mailman.100.1705882547.15798.python-list@ram.dialup.fu-berlin.de>
References : 1 2
Cameron Simpson <
cs@cskk.id.au> writes:
I would need to know more about what it might be used for. What larger
problem led you to writing a `dict` subclass with this particular
`__missing__` implementation?
The Python Library Reference (Release 3.13.0a0) contains:
|>>> class Default(dict):
|... def __missing__(self, key):
|... return key
. Otherwise, I personally might think of:
|>>> class DefaultsToKey( dict ):
|... def __missing__( self, key ):
|... return key
.