Skip to content

Instantly share code, notes, and snippets.

@jdunck
Created May 23, 2012 20:35
Show Gist options
  • Save jdunck/2777641 to your computer and use it in GitHub Desktop.
Save jdunck/2777641 to your computer and use it in GitHub Desktop.
class BasicItemFallback(object):
def __init__(self, property_name):
self.property_name = property_name
def __get__(self, obj, type=None):
return getattr(obj.item, self.property_name)
def __set__(self, obj, value):
# or maybe raise?
setattr(obj.item, self.property_name)
class ItemUser(...)
some_item_property = BasicItemFallback('some_item_property')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment