class NestedDict(dict):

    def __missing__(self, key):
        self[key] = NestedDict()
return self[key]
table = NestedDict()
table['A']['B1']['C1'] = 1
table
Multi-level defaultdict with variable depth?