Created
May 31, 2012 17:34
-
-
Save mgrouchy/2844942 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 AttrDict(dict): | |
"""override dict class so we can access attributes using 'dot' notation | |
ex/ dict.value | |
""" | |
def __init__(self, **kwargs): | |
dict.__init__(self, kwargs) | |
self.__dict__ = self | |
def __getstate__(self): | |
return self | |
def __setstate__(self, state): | |
self.update(state) | |
self.__dict__ = self |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment