Is there a way to make defaultdict also the default for defaultdict? (i.e. recursive defaultdict of infinite level?)
I want to be able to do:
x = defaultdict(...stuff...) x[0][1][0] {}
So, I can do x = defaultdict(defaultdict) , but this is only the second level:
x[0] {} x[0][0] KeyError: 0
There are recipes that can do this. But can this be done simply using the usual defaultdict arguments?
Please note that here the question is asked how to make a recursive defaultdict of infinite level, so it differs from Python: defaultdict from defaultdict? which was how to make a two-level defaultdict.
I probably end up just using the bundle template, but when I realized that I did not know how to do this, it interested me.
python recursion defaultdict
Corley Brigman Oct 04 '13 at 19:28 2013-10-04 19:28
source share