Created
May 23, 2018 07:13
-
-
Save rbarzic/3363b5ce48f92e90aae545d850d6813d to your computer and use it in GitHub Desktop.
Autovification in Python using defaultdict
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
# From https://stackoverflow.com/questions/5369723/multi-level-defaultdict-with-variable-depth/8702435#8702435 | |
from collections import defaultdict | |
nested_dict = lambda: defaultdict(nested_dict) | |
nest = nested_dict() | |
nest[0][1][2][3][4][5] = 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment