UnboundMethodType and MethodType

Schüle Daniel uval at rz.uni-karlsruhe.de
Tue Feb 7 23:22:25 EST 2006


Hello all,

 >>> class Q:
...     def bar(self):
...             pass
...
 >>> import types
 >>> types.UnboundMethodType is types.MethodType
True
 >>>
 >>> type(Q.bar)
<type 'instancemethod'>
 >>>
 >>> q = Q()
 >>> type(q.bar)
<type 'instancemethod'>
 >>>
 >>> type(q.bar) is types.UnboundMethodType
True
 >>> q.bar
<bound method Q.bar of <__main__.Q instance at 0x4042756c>>
 >>>

I think is not very consistent
notice q.bar is bounded although type(q.bar)
says it's types.UnboundedMethodType
what do you think?

Regard, Daniel




More information about the Python-list mailing list