/Doc/c-api/bool.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 54 lines · 29 code · 25 blank · 0 comment · 0 complexity · 56d4cd4808b6388d39f7f83b5c0ebdff MD5 · raw file

  1. .. highlightlang:: c
  2. .. _boolobjects:
  3. Boolean Objects
  4. ---------------
  5. Booleans in Python are implemented as a subclass of integers. There are only
  6. two booleans, :const:`Py_False` and :const:`Py_True`. As such, the normal
  7. creation and deletion functions don't apply to booleans. The following macros
  8. are available, however.
  9. .. cfunction:: int PyBool_Check(PyObject *o)
  10. Return true if *o* is of type :cdata:`PyBool_Type`.
  11. .. versionadded:: 2.3
  12. .. cvar:: PyObject* Py_False
  13. The Python ``False`` object. This object has no methods. It needs to be
  14. treated just like any other object with respect to reference counts.
  15. .. cvar:: PyObject* Py_True
  16. The Python ``True`` object. This object has no methods. It needs to be treated
  17. just like any other object with respect to reference counts.
  18. .. cmacro:: Py_RETURN_FALSE
  19. Return :const:`Py_False` from a function, properly incrementing its reference
  20. count.
  21. .. versionadded:: 2.4
  22. .. cmacro:: Py_RETURN_TRUE
  23. Return :const:`Py_True` from a function, properly incrementing its reference
  24. count.
  25. .. versionadded:: 2.4
  26. .. cfunction:: PyObject* PyBool_FromLong(long v)
  27. Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
  28. truth value of *v*.
  29. .. versionadded:: 2.3