[issue10533] defaultdict constructor with a concrete value

Steve Holden report at bugs.python.org
Thu Nov 25 18:54:35 CET 2010


Steve Holden <steve at holdenweb.com> added the comment:

On 11/25/2010 11:48 AM, Eric Smith wrote:
> 
> Eric Smith <eric at trueblade.com> added the comment:
> 
> How about:
> 
> from collections import defaultdict
> 
> class defaultdict_value(defaultdict):
>     def __init__(self, value):
>         defaultdict.__init__(self, lambda : value)
> 
> x = defaultdict_value(3)
> print(x[1])
> 
> ----------

+1

But I'd call it defaultdict_const().

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17       http://us.pycon.org/
See Python Video!       http://python.mirocommunity.org/
Holden Web LLC                 http://www.holdenweb.com/

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10533>
_______________________________________


More information about the Python-bugs-list mailing list