Background: I am trying to understand why static and class methods are not callable while being descriptors, while ordinary methods of a class (i.e. methods of a class which are neither static or class methods) and functions which are not attributes of classes are both descriptors and callable.
In Python, what is the definition of a callable type?
From https://docs.python.org/3/reference/datamodel.html
Callable types These are the types to which the function call operation (see section Calls) can be applied:
Is the operator for "the function call operatation"
()
? So is a callable type defined as a type whose instances the function call operator()
can be applied to?From https://docs.python.org/3/reference/expressions.html#calls
The primary must evaluate to a callable object (user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances, and all objects having a
__call__()
method are callable).Does it mean that a callable type may or might not have a
__call__()
method? If a class has a__call__()
method, then it must be a callable type? If a class doesn't have a__call__()
method, then it might or might not be a callable type?Do "user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances" not have a
__call__()
method? Are they instances of callable types? What specific types do they have respectively?
Thanks.