Created
May 2, 2020 22:45
-
-
Save m4nh/a993d8b5470dba00b5a0c00045fff5dc to your computer and use it in GitHub Desktop.
#python #hack to build recursive #tree with #dict
This file contains 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
# Definition | |
from collections import defaultdict | |
def tree(): return defaultdict(tree) | |
# Sample | |
t = tree() | |
t['one']['two']['three']=1.23 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment