Raymond Hettinger added the comment:

Take a look at the __missing__(key) method for the regular dict API to see if 
it meets your needs.  It is in the ``d[key]`` section at 
https://docs.python.org/3/library/stdtypes.html#dict 

>>> class UpperDict(dict):
        def __missing__(self, key):
            return key.upper()

>>> d = UpperDict()
>>> print(d['tom'])
TOM

----------
assignee:  -> rhettinger
nosy: +rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30408>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to