default dict value python code example
Example 1: python defaultdict default value
d = defaultdict(lambda:1)
Example 2: python defaultdict to dict
>>> #You can simply call dict:
>>> a
defaultdict(<type 'list'>, {'1': ['b', 'a'], '3': ['b'], '2': ['a']})
>>> dict(a)
{'1': ['b', 'a'], '3': ['b'], '2': ['a']}
# but remember that a defaultdict is a dict
# (with some special behavior, check source):
>>> isinstance(a, dict)
True