Read the docs :
The first argument provides the initial value for the default_factory attribute; the default value is None. All other arguments are treated as if they were passed to the dict constructor , including keywords.
from collections import defaultdict d=defaultdict(int, zip(range(1,10),range(50,61)))
Or the d dictionary is given:
from collections import defaultdict d=dict(zip(range(1,10),range(50,61))) my_default_dict = defaultdict(int,d)
Jochen Ritzel Sep 24 '11 at 12:50 2011-09-24 12:50
source share