Skip to content

Instantly share code, notes, and snippets.

@hannal
Created January 24, 2016 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannal/d45d8dedfd3c15d6d524 to your computer and use it in GitHub Desktop.
Save hannal/d45d8dedfd3c15d6d524 to your computer and use it in GitHub Desktop.
class LikeDict(dict):
def __getattribute__(self, attr):
return self[attr]
def __setattr__(self, attr, value):
self[attr] = value
class LikeDict2(object):
def __getitem__(self, key):
return getattr(self, key)
def __setitem__(self, key, value):
setattr(self, key, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment