11 import collections.abc
15 """Allow lookups in multiple dictionaries while writing to one.
17 A StackedDict references a list of other dictionaries.
18 Reads try each dictionary in sequence, succeeding with the first dictionary
19 that contains the target key. Modifications go to the last dictionary
22 Notes: No attempt is made to deal with keys duplicated between dictionaries;
23 len() and __iter__ will process them all. __delitem__ is not implemented.
26 >>> from pprint import pprint
30 >>> d = StackedDict (d1, d2, d3)
58 {'a': 'b', 'c': 10, 'e': 'f', 'x': 20}
74 for d
in self.
dicts[:-1]:
83 return sum([len(d)
for d
in self.
dicts])
93 """Some code still uses this.
95 >>> d = StackedDict (d1)
107 d.update(self.
dicts[i])