物件協定¶
-
PyObject *Py_GetConstant(unsigned int constant_id)¶
- 為 穩定 ABI 的一部分 自 3.13 版本開始.
Get a strong reference to a constant.
如果 constant_id 無效,則設定一個例外並回傳
NULL。constant_id 必須是這些常數識別字之一:
常數識別字
數值
回傳物件
-
Py_CONSTANT_NONE¶
0-
Py_CONSTANT_FALSE¶
1-
Py_CONSTANT_TRUE¶
2-
Py_CONSTANT_ELLIPSIS¶
3-
Py_CONSTANT_NOT_IMPLEMENTED¶
4-
Py_CONSTANT_ZERO¶
50-
Py_CONSTANT_ONE¶
61-
Py_CONSTANT_EMPTY_STR¶
7''-
Py_CONSTANT_EMPTY_BYTES¶
8b''-
Py_CONSTANT_EMPTY_TUPLE¶
9()Numeric values are only given for projects which cannot use the constant identifiers.
在 3.13 版被加入.
在 CPython 中,所有這些常數都是不滅的。
-
Py_CONSTANT_NONE¶
-
PyObject *Py_GetConstantBorrowed(unsigned int constant_id)¶
- 為 穩定 ABI 的一部分 自 3.13 版本開始.
Similar to
Py_GetConstant(), but return a borrowed reference.This function is primarily intended for backwards compatibility: using
Py_GetConstant()is recommended for new code.The reference is borrowed from the interpreter, and is valid until the interpreter finalization.
在 3.13 版被加入.
-
PyObject *Py_NotImplemented¶
The
NotImplementedsingleton, used to signal that an operation is not implemented for the given type combination.
-
Py_RETURN_NOTIMPLEMENTED¶
Properly handle returning
Py_NotImplementedfrom within a C function (that is, create a new strong reference toNotImplementedand return it).
-
Py_PRINT_RAW¶
Flag to be used with multiple functions that print the object (like
PyObject_Print()andPyFile_WriteObject()). If passed, these functions use thestr()of the object instead of therepr().
-
int PyObject_Print(PyObject *o, FILE *fp, int flags)¶
Print an object o, on file fp. Returns
-1on error. The flags argument is used to enable certain printing options. The only option currently supported isPy_PRINT_RAW; if given, thestr()of the object is written instead of therepr().
- int