Skip to content

Instantly share code, notes, and snippets.

View adugin's full-sized avatar

Andrey Dugin adugin

View GitHub Profile
@adugin
adugin / tree
Created December 26, 2014 13:51
def tree(levels=0, func=None):
if levels > 0 and func:
return defaultdict(reduce(lambda f, i: lambda: defaultdict(f), xrange(levels-1), func))
else:
return defaultdict(tree)