Hello all, 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". <code> import types def hello(): print "hello" class C: def hello(self): print "hello" c=C() 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 f=c.hello f() #4 </code> <output> False True True hello </output> Am I missing an subtelty of bound/unbound-ness? Thanks in advance, Gareth.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4