[issue10533] defaultdict constructor with a concrete value

Eric Smith report at bugs.python.org
Thu Nov 25 18:48:10 CET 2010


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])

----------

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


More information about the Python-bugs-list mailing list