Dictionaries with variable default.
antoon.pardon at rece.vub.ac.be
Mon Nov 3 12:04:48 CET 2014
Is it possible to have a default dictionary where the default is dependant
on the key?
I was hoping something like this might work:
>>> m = defaultdict(lambda key: key+1)
But it obviously doesn't:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: <lambda>() takes exactly 1 argument (0 given)
More information about the Python-list