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 eric.araujo, eric.smith, holdenweb, lukasz.langa, michael.foord, rhettinger
Date 2010-11-25.19:09:14
SpamBayes Score 5.5754996e-09
Marked as misclassified No
Message-id <1290712156.31.0.802571715367.issue10533@psf.upfronthosting.co.za>
In-reply-to
Content
> It would be very handy to allow for concrete values as well.

Do you have use cases for a concrete integer value that isn't zero?

Since we can currently use defaultdict(int) or defaultdict(tuple), is the purpose just to create a more direct spelling of the same thing?  The docs for defaultdict also show a general purpose way to generate any default constant (though that way isn't obvious if you haven't seen it in the docs).

I'm reluctant to add yet another variant.  We already have __missing__, defaultdict, Counter, dict.get, and dict.setdefault().

The docs for dictionaries need to make clear that Guido has already provided an idiom to be the one obvious way to do it:

    class MyConst(dict):
        def __missing__(self, key):
            return myconst

That was really the whole point of adding __missing__ in the first place.  The OP's proposal amounts to rejecting Guido's design which provides a very good general purpose solution.
History
Date User Action Args
2010-11-25 19:09:16rhettingersetrecipients: + rhettinger, holdenweb, eric.smith, eric.araujo, michael.foord, lukasz.langa
2010-11-25 19:09:16rhettingersetmessageid: <1290712156.31.0.802571715367.issue10533@psf.upfronthosting.co.za>
2010-11-25 19:09:14rhettingerlinkissue10533 messages
2010-11-25 19:09:14rhettingercreate