proomt

Search

Search posts, papers, and topics

All posts

Lerner Consulting BlogReuven Lerner1 min readintermediate

Python callables: Any object that defines __call__

Summary

A callable in Python is any object that implements `__call__`. The post shows a minimal class with `__call__` and notes that the built‑in `callable()` checks for that method.

  • Callable isn’t limited to functions or classes; any object with a `__call__` method qualifies.
  • `callable(obj)` returns `True` if `obj.__call__` exists.

Understanding that any object can be made callable lets you design flexible APIs (e.g., function‑like objects, lazy evaluation, or strategy objects) without relying on plain functions.

3/10

Related reading

  1. Quiz: Thinking Recursively in Python

    This is an interactive quiz from Real Python designed to test understanding of recursive thinking in Python. It covers identifying recursive structures, writing base and recursive cases, managing state, and using caching to avoid recomputation.

    Real Pythonrealpython.com1 min