-
-
Save toshok/d64141a11bf13b6f6132 to your computer and use it in GitHub Desktop.
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 TestDescriptor(object): | |
def __init__(self, initval, name): | |
self.val = initval | |
self.name = name | |
def __get__(self, obj, objtype): | |
print "retrieving", self.name | |
return self.val | |
def __set__(self, obj, val): | |
print "updating", self.name | |
self.val = val | |
class MyClass(object): | |
x = TestDescriptor(10, "x") | |
class MySubclass(MyClass): | |
def __init__(self): | |
print super(MyClass, self).x | |
x = MySubclass() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment