繁体   English   中英

function 是 python 中内置 class '函数'的实例吗?

[英]is a function an instance of built-in class 'function' in python?

In python, when we create a function, the class or type of that function is function :

 def temp():
    pass

>>> type(temp)
<class 'function'>
>>> temp.__class__
<class 'function'>

我想知道代码def ~():是否调用了内置 class function 的__call__ function 我想查看内置 class function的源代码,但我不知道它在哪里。

如果你知道,请回答。

来自@IainShelvington 在评论中给出的链接: https://github.com/python/cpython/blob/master/Objects/funcobject.c

源代码中的任何地方都没有__call__调用或引用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM