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 <>
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
Date User Action Args
2019-09-29 16:49:50rhettingersetrecipients: + rhettinger, ExplodingCabbage
2019-09-29 16:49:50rhettingersetmessageid: <>
2019-09-29 16:49:50rhettingerlinkissue38315 messages
2019-09-29 16:49:50rhettingercreate