Skip to content

Instantly share code, notes, and snippets.

@thewickedaxe
Created July 28, 2017 23:00
Show Gist options
  • Select an option

  • Save thewickedaxe/7b1c4d2f47d04bde56488a057b3e7c6c to your computer and use it in GitHub Desktop.

Select an option

Save thewickedaxe/7b1c4d2f47d04bde56488a057b3e7c6c to your computer and use it in GitHub Desktop.
Auto Vivification in Python
from collections import defaultdict
tree = lambda: defaultdict(tree)
t = tree()
t[1][2][3] = 4
t[1][3][3] = 5
t[1][2]['test'] = 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment