Skip to content

Instantly share code, notes, and snippets.

@defuz
Created August 14, 2013 19:15
Show Gist options
  • Save defuz/6234508 to your computer and use it in GitHub Desktop.
Save defuz/6234508 to your computer and use it in GitHub Desktop.
class BaseModel(object):
def __init__(self, params, **params2):
self._data = dict(params, params2)
def __getattr__(self, name):
try:
return self._data[name]
except KeyError:
raise AttributeError(self, name)
def __iter__(self):
return self._data.iteritems()
@property
def as_dict(self):
return self._data.copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment