Skip to content

Instantly share code, notes, and snippets.

@dbbbit
Created December 15, 2015 04:29
Show Gist options
  • Save dbbbit/ad1cabff2a2d302cf792 to your computer and use it in GitHub Desktop.
Save dbbbit/ad1cabff2a2d302cf792 to your computer and use it in GitHub Desktop.
class Field(object):
def __init__(self, value=None):
self.value = value
def __get__(self, instance, owner):
print("getting")
return self.value
def __set__(self, instance, value):
self.value = value
class AModel(object):
f = Field(12)
if __name__ == "__main__":
m = AModel()
m.f = m.f + 1
print m.f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment