Created
June 12, 2011 17:19
-
-
Save peterbe/1021777 to your computer and use it in GitHub Desktop.
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
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