Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created June 12, 2011 17:19
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 peterbe/1021777 to your computer and use it in GitHub Desktop.
Save peterbe/1021777 to your computer and use it in GitHub Desktop.
class dict_plus(dict):
def __init__(self, *args, **kwargs):
if 'collection' in kwargs: # excess we don't need
kwargs.pop('collection')
dict.__init__(self, *args, **kwargs)
self._wrap_internal_dicts()
def _wrap_internal_dicts(self):
for key, value in self.items():
if isinstance(value, dict):
self[key] = dict_plus(value)
def __getattr__(self, key):
return self[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment