Created
December 9, 2014 17:50
-
-
Save ironpythonbot/c6c348aad753b2d85c9c to your computer and use it in GitHub Desktop.
CodePlex Issue #29192 Plain Text Attachments
This file contains 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 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