I have a data structure which essentially amounts to a nested dictionary. Let\'s say it looks like this:
{\'new jersey\': {\'mercer county\': {\'plumbers\':
defaultdict() is your friend!
defaultdict()
For a two dimensional dictionary you can do:
d = defaultdict(defaultdict) d[1][2] = 3
For more dimensions you can:
d = defaultdict(lambda :defaultdict(defaultdict)) d[1][2][3] = 4