
Definition: In Python, a callable object is any element that can be called like a function — that is, it can be followed by parentheses ()
.
A callable executes some behaviour or returns a value when invoked.
Common callable objects include:
- Functions defined with
def
orlambda
. - Classes, which create instances when called.
- Methods bound to objects.
- Objects implementing the special method
__call__()
.
Practical example
def greet():
return "Hello!"
print(greet()) # → "Hello!"
print(callable(greet)) # → True
class Example:
def __call__(self):
return "I’m callable!"
e = Example()
print(e()) # → "I’m callable!"
Summary
A callable is “anything you can put before parentheses.”
The built-in callable(obj)
function checks if an object is callable.