While reading about the unification of types I stumbled on the fact that built-in types have method_descriptor
s and builtin_function_or_method
s instead of method
s and function
s, why?
>>> list.append
<method 'append' of 'list' objects>
>>> type(list.append)
<class 'method_descriptor'>
>>> [].append
<built-in method append of list object at 0x7f0c4214aef0>
>>> type([].append)
<class 'builtin_function_or_method'>
>>> class A(list):
... def append(self): pass
...
>>> A.append
<function A.append at 0x7f0c42168dd0>
>>> type(A.append)
<class 'function'>
>>> A().append
<bound method A.append of []>
>>> type(A().append)
<class 'method'>
There is no good reason for class A
to subclass list, I just wanted to show that the types differ.