Skip to content

Instantly share code, notes, and snippets.

@internetimagery
Created October 15, 2015 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save internetimagery/39d3f9bd9ce1950eaa3a to your computer and use it in GitHub Desktop.
Save internetimagery/39d3f9bd9ce1950eaa3a to your computer and use it in GitHub Desktop.
nested dict
# http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python/19829714#19829714
class Dict(dict):
def __missing__(s, k):
v = s[k] = type(s)()
return v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment