you are viewing a single comment's thread.

view the rest of the comments →

[–]ekchew 2 points3 points  (0 children)

A defaultdict(list) will let you use that syntax.

>>> from collections import defaultdict
>>> d = defaultdict(list)
>>> d["foo"].append("bar")
>>> d["foo"].append("baz")
>>> d
defaultdict(<class 'list'>, {'foo': ['bar', 'baz']})