source: python/trunk/Doc/c-api/bool.rst

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 1.3 KB
RevLine 
[2]1.. highlightlang:: c
2
3.. _boolobjects:
4
5Boolean Objects
6---------------
7
8Booleans in Python are implemented as a subclass of integers. There are only
9two booleans, :const:`Py_False` and :const:`Py_True`. As such, the normal
10creation and deletion functions don't apply to booleans. The following macros
11are available, however.
12
13
[391]14.. c:function:: int PyBool_Check(PyObject *o)
[2]15
[391]16 Return true if *o* is of type :c:data:`PyBool_Type`.
[2]17
18 .. versionadded:: 2.3
19
20
[391]21.. c:var:: PyObject* Py_False
[2]22
23 The Python ``False`` object. This object has no methods. It needs to be
24 treated just like any other object with respect to reference counts.
25
26
[391]27.. c:var:: PyObject* Py_True
[2]28
29 The Python ``True`` object. This object has no methods. It needs to be treated
30 just like any other object with respect to reference counts.
31
32
[391]33.. c:macro:: Py_RETURN_FALSE
[2]34
35 Return :const:`Py_False` from a function, properly incrementing its reference
36 count.
37
38 .. versionadded:: 2.4
39
40
[391]41.. c:macro:: Py_RETURN_TRUE
[2]42
43 Return :const:`Py_True` from a function, properly incrementing its reference
44 count.
45
46 .. versionadded:: 2.4
47
48
[391]49.. c:function:: PyObject* PyBool_FromLong(long v)
[2]50
51 Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
52 truth value of *v*.
53
54 .. versionadded:: 2.3
Note: See TracBrowser for help on using the repository browser.