Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 17:50
Show Gist options
  • Save ironpythonbot/c6c348aad753b2d85c9c to your computer and use it in GitHub Desktop.
Save ironpythonbot/c6c348aad753b2d85c9c to your computer and use it in GitHub Desktop.
CodePlex Issue #29192 Plain Text Attachments
class Desc(object):
def __init__(self, key):
self.key = key
def __get__(self, instance, owner):
print "__get__ (%s): instance='%s'; owner='%s'" % (self.key, instance, owner)
return self
def __set__(self, instance, value):
print "__set__ (%s): instance='%s'; value='%s'" % (self.key, instance, value)
self.key = value.key
def __repr__(self):
return "<Desc(%s)>" % self.key
class Foo(object):
content_type = Desc("1")
class Bar(Foo):
pass
setattr(Bar, "content_type", Desc("2"))
print "Key:", Bar.content_type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment