Key 4: All objects can be made callable.
To reuse and group code for some task, we group it in the functions classes, and then call it with different inputs. The objects that have a
__call__ attribute are callable and
__call__ is the entry point. For the C class,
tp_call is checked in its structure:
>>> def func(): # a function ... print("adf") ... >>> func() adf >>> func.__call__() #implicit call method adf >>> func.__class__.__call__(func) adf >>> func.__call__ <method-wrapper '__call__' of function object at 0x7ff7d9f24ea0> >>> class C: #a callable class ... def __call__(self): ... print("adf") ... >>> c = C() >>> c() adf >>> c.__call__() #implicit passing of self adf >>> c.__class__.__call__(c) #explicit passing of ...