defaultdict of arbitrary depth

Daniel millerdev at gmail.com
Tue Aug 21 20:49:51 EDT 2007


Any reason why this wouldn't work?

>>> from collections import defaultdict
>>> def rdict(*args, **kw):
...     return defaultdict(rdict, *args, **kw)
...
>>> d = rdict()
>>> d[1][2][3][4][5] # ...
defaultdict(<function rdict at 0x61370>, {})


~ Daniel




More information about the Python-list mailing list