Skip to content

Instantly share code, notes, and snippets.

@igorsobreira
Created March 8, 2012 17:50
Show Gist options
  • Save igorsobreira/2002326 to your computer and use it in GitHub Desktop.
Save igorsobreira/2002326 to your computer and use it in GitHub Desktop.
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