-
-
Save adugin/2fea571df1279e798cd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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