Overload () operator in Python
You can make an object callable by implementing the __call__
method:
class FunctionLike(object): def __call__(self, a): print("I got called with {!r}!".format(a))fn = FunctionLike()fn(10)# --> I got called with 10!