Skip to content

Instantly share code, notes, and snippets.

@m4nh
Created May 2, 2020 22:45
Show Gist options
  • Save m4nh/a993d8b5470dba00b5a0c00045fff5dc to your computer and use it in GitHub Desktop.
Save m4nh/a993d8b5470dba00b5a0c00045fff5dc to your computer and use it in GitHub Desktop.
#python #hack to build recursive #tree with #dict
# 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