Boolean Objects - Python 3.12.0a3 documentation 编辑

Booleans in Python are implemented as a subclass of integers. There are only two booleans, Py_False and Py_True. As such, the normal creation and deletion functions don’t apply to booleans. The following macros are available, however.

int PyBool_Check(PyObject *o)

Return true if o is of type PyBool_Type. This function always succeeds.

PyObject *Py_False

The Python False object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.

PyObject *Py_True

The Python True object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.

Py_RETURN_FALSE

Return Py_False from a function, properly incrementing its reference count.

Py_RETURN_TRUE

Return Py_True from a function, properly incrementing its reference count.

PyObject *PyBool_FromLong(long v)
Return value: New reference. Part of the Stable ABI.

Return a new reference to Py_True or Py_False depending on the truth value of v.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:68 次

字数:1701

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文