Boolean Objects

Booleans in Python are implemented as a subclass of integers. There are onlytwo booleans,Py_False andPy_True. As such, the normalcreation and deletion functions don’t apply to booleans. The following macrosare available, however.

PyTypeObjectPyBool_Type
Μέρος τουΣταθερό ABI.

This instance ofPyTypeObject represents the Python boolean type; itis the same object asbool in the Python layer.

intPyBool_Check(PyObject*o)

Return true ifo is of typePyBool_Type. This function alwayssucceeds.

PyObject*Py_False

The PythonFalse object. This object has no methods and isimmortal.

Άλλαξε στην έκδοση 3.12:Py_False isimmortal.

PyObject*Py_True

The PythonTrue object. This object has no methods and isimmortal.

Άλλαξε στην έκδοση 3.12:Py_True isimmortal.

Py_RETURN_FALSE

ReturnPy_False from a function.

Py_RETURN_TRUE

ReturnPy_True from a function.

PyObject*PyBool_FromLong(longv)
Επιστρεφόμενη τιμή: New reference. Μέρος τουΣταθερό ABI.

ReturnPy_True orPy_False, depending on the truth value ofv.