def __missing__(self, key):
        if self.default_factory is None:
            raise KeyError(key)
        else:
            ret = self[key] = self.default_factory(name=key)
            return ret
def clear(self):
    for unused_ in range(len(self._items)):
      self.remove_item(self._items[0])