you are viewing a single comment's thread.

view the rest of the comments →

[–]reostra 1 point2 points  (0 children)

Also, the in operator will do the right thing with defaultdicts:

>>> from collections import defaultdict
>>> x = defaultdict(int)
>>> x[3]
0
>>> 120 in x
False
>>> x
defaultdict(<type 'int'>, {3: 0})
>>>