在 python 中输入 'builtin-function' 或 'class'

Is type a 'builtin-function' or 'class' in python

我正在查看 python 文档并在内置函数部分找到了 'type()'。 https://docs.python.org/3/library/functions.html

但是,当我查看实际细节时,我将其视为一个 class,它有 1 个或 3 个参数。 https://docs.python.org/3/library/functions.html#type

>>> type(type)
<class 'type'>
>>> type(pow)
<class 'builtin_function_or_method'>

如果它不是函数,为什么它列在内置函数部分下。?我错过了什么吗?

Python 有许多可调用的对象。有些更像是函数,即使它们实际上是 类 或类型。区别并不是那么重要,更多的是实现细节。

例如,list() 为您提供了一个新列表。那是因为 list 是一种类型。但是如果你想把它看作是一个生成列表的函数,那也没关系。