Created
July 28, 2017 23:00
-
-
Save thewickedaxe/7b1c4d2f47d04bde56488a057b3e7c6c to your computer and use it in GitHub Desktop.
Auto Vivification in Python
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
| 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