micropython-lib/python-stdlib/collections.defaultdict/test_defaultdict.py

11 wiersze
171 B
Python

from collections import defaultdict
d = defaultdict.defaultdict(lambda: 42)
assert d[1] == 42
d[2] = 3
assert d[2] == 3
del d[1]
assert d[1] == 42
assert "foo" not in d