I was just thinking; so in Python, the ()
you use to call a function/class/etc... is really an operator like any other, specifically this one maps to the __call__()
magic method.
Except... __call__
would then have it's own .__call__
. But surely that can't be the case, eventually it has to bottom out somewhere.
Except it doesn't:
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int.__call__
<method-wrapper '__call__' of type object at 0x58DE7028>
>>> int.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F6F0>
>>> int.__call__.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F590>
>>> int.__call__.__call__.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F6B0>
>>> int.__call__.__call__.__call__.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F870>
>>> int.__call__.__call__.__call__.__call__.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F630>
>>> int.__call__.__call__.__call__.__call__.__call__.__call__.__call__
<method-wrapper '__call__' of method-wrapper object at 0x0300F5F0>
>>>
Obviously some interpreter magic is happening in the background, but what exactly is going on here?