[Python-Dev] isinstance(x, types.UnboundMethodType) feature
g.ladd at eris.qinetiq.com
Tue Jan 20 07:50:40 EST 2004
Whilst writing a routine to perform callbacks, I was performing a check
to ensure the callback method is callable and bound. After checking
"callable(x)" I then check that "x" is bound using "isinstance(x,
types.UnboundMethodType)". It appears the latter returns true if "x" is
a bound or an unbound class/instance method. Please have a look at the
following example. I would expect #3 to return "False".
print isinstance(hello, types.UnboundMethodType) #1
print isinstance(C.hello, types.UnboundMethodType) #2
print isinstance(c.hello, types.UnboundMethodType) #3
# Check it is actualy bound
Am I missing an subtelty of bound/unbound-ness?
Thanks in advance,
More information about the Python-Dev