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 rhettinger
Recipients ExplodingCabbage, rhettinger
Date 2019-09-29.16:49:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569775790.32.0.344903702148.issue38315@roundup.psfhosted.org>
In-reply-to
Content
The __missing__() method already fulfills this need:

   class DoubleDict(dict):

       def __missing__(self, key):
           return key * 2

If desired, it can also add entries:

   class DoubleDict(dict):

       def __missing__(self, key):
           self[key] = value = key * 2
           return value
History
Date User Action Args
2019-09-29 16:49:50rhettingersetrecipients: + rhettinger, ExplodingCabbage
2019-09-29 16:49:50rhettingersetmessageid: <1569775790.32.0.344903702148.issue38315@roundup.psfhosted.org>
2019-09-29 16:49:50rhettingerlinkissue38315 messages
2019-09-29 16:49:50rhettingercreate