Python 3.7+typesterm
types.ClassMethodDescriptorType
descriptors and C wrappers
The type of a raw class method of a built-in C class, such as dict.__dict__['fromkeys']. The C counterpart of classmethod.
Syntax
isinstance(obj, types.ClassMethodDescriptorType)
You only see this type by looking into the class __dict__: accessing dict.fromkeys already runs the descriptor and returns a BuiltinFunctionType bound to the class. Python classes have the same split: __dict__ holds a classmethod object, while dotted access gives a bound method. So code that walks vars(cls) looking for methods sees different types than getattr(cls, name).
Examples
import types
raw = dict.__dict__['fromkeys']
print(isinstance(raw, types.ClassMethodDescriptorType)) # → True
print(isinstance(dict.fromkeys, types.BuiltinFunctionType)) # → True
print(dict.fromkeys('ab', 0)) # → {'a': 0, 'b': 0}
See also
Open in the full glossarydocs.python.orgReport an inaccuracy