2 ms·
It will if you recursively define it: from collections import defaultdict def dd(): return defaultdict(dd) d = dd() d['a']['b']['c'] # => defa
by adambard 12y ago
It will if you recursively define it:
from collections import defaultdict
def dd(): return defaultdict(dd)
d = dd()
d['a']['b']['c'] # => defaultdict(dd, {})
d['a']['b']['c'] = 'test'
d['a']['b']['c'] # => 'test'