What is the purpose of a callable object? What problems do they solve?
They take parameters and return a result depending on those parameters.
A callable is just an abstract form of a function resp an interface that defines that an object acts like a function (i.e. accepts parameters).
As functions are first class objects, it is obvious that functions are callable objects. If you are talking about the __call__
method, this is just one of the many special methods with which you can overload the behavior of custom objects, e.g. for arithmetic operations or also defining what happens if you call an object.
One idea why to use such is to have some kind of factory object that itself creates other objects.