This callable()
function returns a Boolean stating whether the object argument appears callable.
callable(object)
Here,
Note: If callable()
returns True, it is still possible that a call fails, but if it is False, calling object will never succeed.
Also, note that classes are callable (calling a class returns a new instance); class instances are callable if they have a __call__()
method.
>>> class Class1:
... pass
...
>>> def func1():
... pass
...
>>> callable(Class1)
True
>>> callable(func1)
True
>>> callable(100)
False
>>> callable('hello')
False
>>> callable(True)
False