Paul Rubin wrote:
Per Freem <perfr...@yahoo.com> writes:
2] is there an easy way to have nested defaultdicts? ie i want to say
that my_dict = defaultdict(defaultdict(int)) -- to reflect the fact
that my_dict is a dictionary, whose values are dictionary that map to
ints. but that syntax is not valid.

my_dict = defaultdict(lambda: defaultdict(int))
or
    my_dict = defaultdict(functools.partial(defaultdict, int))

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to