Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

callable()

Checks whether an object appears to support the calling protocol.

Version: Python 3.14; repository image, production runtime not attested

Syntax

callable(object, /)

Checks whether an object appears to support the calling protocol.

A callable can still reject a particular argument list. The predicate makes no signature guarantee.

A callable object may be a function, a class or an instance whose type implements __call__. The test reports True for len and False for the integer 4. It checks no proposed arguments: calling len with no argument still raises TypeError because len requires an object.

class Scale:
    def __call__(self, x): return 2*x
f = Scale()
assert callable(Scale) and callable(f) and f(3) == 6 and not callable(4)

Examples

print(callable(len), callable(4))
try:
    len()
except TypeError as error:
    print(type(error).__name__)

Result

True False
TypeError

A callable object may be a function, a class or an instance whose type implements `__call__`. The test reports True for len and False for the integer 4. It checks no proposed arguments: calling len with no argument still raises TypeError because len requires an object.

Sources