这真的是__call__一路下来吗?

时间:2016-12-01 10:35:30

标签: python

我只是在思考;所以在Python中,用来调用函数/类/等的()实际上是一个像其他任何函数一样的运算符,特别是这个映射到__call__()魔术方法。

除了...... __call__然后拥有它自己的.__call__。但肯定不是这样,最终它必须在某个地方找到底线。

除非没有:

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>
>>>

显然一些翻译魔术正在后台发生,但到底发生了什么?

0 个答案:

没有答案