Writing a Non-Data Descriptor
问题 I am learning about descriptors in python. I want to write a non-data descriptor but the class having the descriptor as its classmethod doesn't call the __get__ special method when I call the classmethod. This is my example (without the __set__ ): class D(object): "The Descriptor" def __init__(self, x = 1395): self.x = x def __get__(self, instance, owner): print "getting", self.x return self.x class C(object): d = D() def __init__(self, d): self.d = d And here is how I call it: >>> c = C(4) >