函数对象 ¶
There are a few functions specific to Python functions.
-
type
PyFunctionObject
¶
-
The C structure used for functions.
-
PyTypeObject
PyFunction_Type
¶
-
This is an instance of
PyTypeObjectand represents the Python function type. It is exposed to Python programmers astypes.FunctionType.
-
int
PyFunction_Check
(
PyObject
*
o
)
¶
-
返回 True 若 o is a function object (has type
PyFunction_Type). The parameter must not beNULL. This function always succeeds.
-
PyObject
*
PyFunction_New
(
PyObject
*
code
,
PyObject
*
globals
)
¶
-
返回值:新引用。
Return a new function object associated with the code object code . globals must be a dictionary with the global variables accessible to the function.
The function’s docstring and name are retrieved from the code object.
__module__检索自 globals . The argument defaults, annotations and closure are set toNULL.__qualname__is set to the same value as the code object’sco_qualname字段。
-
PyObject
*
PyFunction_NewWithQualName
(
PyObject
*
code
,
PyObject
*
globals
,
PyObject
*
qualname
)
¶
-
返回值:新引用。
As
PyFunction_New(), but also allows setting the function object’s__qualname__属性。 qualname should be a unicode object orNULL;若NULL,__qualname__attribute is set to the same value as the code object’sco_qualname字段。Added in version 3.3.