|
|
|
|
|
by rekwah
1871 days ago
|
|
You can expand this a bit to make it n-level depth (until you blow the stack). def tree():
return defaultdict(tree)
>>> t = tree()
>>> t['a']['b']['c'] = 10
>>> t
defaultdict(<function tree at 0x10c40df28>, {'a':
defaultdict(<function tree at 0x10c40df28>, {'b':
defaultdict(<function tree at 0x10c40df28>, {'c': 10})})})
|
|