I would like to nest an arbitrary number of defaultdicts like so:
from collections import defaultdict
D = defaultdict( lambda:defaultdict(int) )
this works fine as described earlier.
Now I'm looking for the way/function to do this for an arbitrary depth: so for instance I'd like to have a function
def Gen_DDict( dim=3 ):
"code I'm looking for"
that will return this for dim=3:
defaultdict( lambda : defaultdict( lambda : defaultdict(int) ) )