Callable

In Python, a callable is any object that can be called like a function, such as a function, class, or object implementing __call__()

« Back to Glossary Index

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 or lambda.
  • 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.

« Back to Glossary Index