4 # from jaraco.collections 3.3
5 class FreezableDefaultDict(collections.defaultdict):
7 Often it is desirable to prevent the mutation of
8 a default dict after its initial construction, such
9 as to prevent mutation during iteration.
11 >>> dd = FreezableDefaultDict(list)
20 def __missing__(self, key):
21 return getattr(self, '_frozen', super().__missing__)(key)
24 self._frozen = lambda key: self.default_factory()
27 class Pair(collections.namedtuple('Pair', 'name value')):
30 return cls(*map(str.strip, text.split("=", 1)))