I would like to expand on the autovivification example given in a previous answer from nosklo to allow dictionary access by tuple.
nosklo\'s solution looks like th
This seems to work
def __setitem__(self, key, value): if isinstance(key, tuple): node = self for i in key[:-1]: try: node = dict.__getitem__(node, i) except KeyError: node = node[i] = type(self)() return dict.__setitem__(node, i, value) return dict.__setitem__(self, key, value)