Python function-callable (object)
Description: checks whether the object is callable. If True is returned, the object may still fail to be called. if False is returned, the object called ojbect will never succeed.
Note: The class is callable, and the class instance can only call the _ call _ () method.
Version: This function is available in python2.x. However, it is removed from Python and added in versions later than Python.
Return True if the object argument appears callable, False if not. if this returns true, it is still possible that a call fails, but if it is false, calling object will never succeed. note that classes are callable (calling a class returns a new instance); class instances are callable if they have a _ call _ () method.
Code example:
>>> callable(0)False>>> callable("mystring")False>>> def add(a, b):… return a + b…>>> callable(add)True>>> class A:… def method(self):… return 0…>>> callable(A)True>>> a = A()>>> callable(a)False>>> class B:… def __call__(self):… return 0…>>> callable(B)True>>> b = B()>>> callable(b)True