Python callables: Any object that defines __call__

Python callables: Any object that defines __call__

What is a “callable” in Python? Typically, a function or class.

But really, it’s anything with __call__ defined:

class MyClass:
    def __call__(self):
        return 'Hi!'
m = MyClass()
m()  # 'Hi!'

The “callable” builtin basically returns True if it finds __call__.