Created
March 8, 2012 17:50
-
-
Save igorsobreira/2002326 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 _O(dict): | |
"""Makes a dictionary behave like an object.""" | |
def __getattr__(self, name): | |
try: | |
return self[name] | |
except KeyError: | |
raise AttributeError(name) | |
def __setattr__(self, name, value): | |
self[name] = value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment