Why is "aClass.aProperty" not callable?
python
Solution
You're digging into the world of `descriptors`. `A.p` is a `property` and properties are descriptors. It's a class that has magic methods (`__get__`, `__set__` ...) which get called when the descriptor is accessed on an instance. The particular method accessed depends on how it's accessed of course. Accessing a descriptor on a class simply returns the descriptor itself and no magic is performed -- In this case, the `property` descriptor isn't callable so you get an error.
Notice what happens if you call `__get__`:
class A(object):
@property
def p(self):
return 2
a = A()
print (A.p.__get__(a)) #2
`foo = A.p.__get__(a)` is what actually happens under the hood when you do `foo = a.p`. I think that's pretty spiffy...
Problem
``` class A: @property def p(self): return 2 def q(self): return 2 a = A() A.p(a) #>> TypeError: 'property' object is not callable A.q(a) #>> no error, returns 2 ``` Why is this? I understand if I referred to the property on an instance : a.p would simply return the method return value, but I am trying to start with the property on the class. I would have expected no error above, with both evaluating to 2.