Created
December 22, 2011 06:42
-
-
Save simensen/1509272 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Entity: | |
def register_fields(self, cls, fields): | |
for name in fields: | |
setattr(cls, name, property(lambda self: self.get_value(name)) | |
def get_value(self, name): | |
return self.json[name] | |
class Org(Entity): | |
def __init__(self): | |
self.register_fields(self.__class__, ["avatar_url", "billing_email"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment