@@ -0,0 +1,1220 @@
+import collections%0Aimport itertools%0A%0A%0A# from jaraco.collections 3.5%0Aclass DictStack(list, collections.abc.Mapping):%0A    %22%22%22%0A    A stack of dictionaries that behaves as a view on those dictionaries,%0A    giving preference to the last.%0A%0A    %3E%3E%3E stack = DictStack(%5Bdict(a=1, c=2), dict(b=2, a=2)%5D)%0A    %3E%3E%3E stack%5B'a'%5D%0A    2%0A    %3E%3E%3E stack%5B'b'%5D%0A    2%0A    %3E%3E%3E stack%5B'c'%5D%0A    2%0A    %3E%3E%3E stack.push(dict(a=3))%0A    %3E%3E%3E stack%5B'a'%5D%0A    3%0A    %3E%3E%3E set(stack.keys()) == set(%5B'a', 'b', 'c'%5D)%0A    True%0A    %3E%3E%3E set(stack.items()) == set(%5B('a', 3), ('b', 2), ('c', 2)%5D)%0A    True%0A    %3E%3E%3E dict(**stack) == dict(stack) == dict(a=3, c=2, b=2)%0A    True%0A    %3E%3E%3E d = stack.pop()%0A    %3E%3E%3E stack%5B'a'%5D%0A    2%0A    %3E%3E%3E d = stack.pop()%0A    %3E%3E%3E stack%5B'a'%5D%0A    1%0A    %3E%3E%3E stack.get('b', None)%0A    %3E%3E%3E 'c' in stack%0A    True%0A    %22%22%22%0A%0A    def __iter__(self):%0A        dicts = list.__iter__(self)%0A        return iter(set(itertools.chain.from_iterable(c.keys() for c in dicts)))%0A%0A    def __getitem__(self, key):%0A        for scope in reversed(self):%0A            if key in scope:%0A                return scope%5Bkey%5D%0A        raise KeyError(key)%0A%0A    push = list.append%0A%0A    def __contains__(self, other):%0A        return collections.abc.Mapping.__contains__(self, other)%0A

Add DictStack from jaraco.collections.