Skip to content

Instantly share code, notes, and snippets.

@civic
Last active December 15, 2015 07:19
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 civic/5222245 to your computer and use it in GitHub Desktop.
Save civic/5222245 to your computer and use it in GitHub Desktop.
class Dynamic:
def __setattr__(self, name, value):
self.__dict__[name] = value
def __getattr__(self, name):
return self.__dict__[name]
d = Dynamic()
d.hoge = 'bar'
d.neko = 'nyan'
print(d.hoge) #bar
print(d.neko) #nyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment