Skip to content

Instantly share code, notes, and snippets.

@adugin
Created December 26, 2014 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adugin/2fea571df1279e798cd6 to your computer and use it in GitHub Desktop.
Save adugin/2fea571df1279e798cd6 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment