blob: 4479bc69dfe03bd401b895d94e891a8d75dad1d6 [file] [log] [blame]
Georg Brandl54a3faa2008-01-20 09:30:57 +00001.. 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
14.. cfunction:: int PyBool_Check(PyObject *o)
15
16 Return true if *o* is of type :cdata:`PyBool_Type`.
17
18
19.. cvar:: PyObject* Py_False
20
21 The Python ``False`` object. This object has no methods. It needs to be
22 treated just like any other object with respect to reference counts.
23
24
25.. cvar:: PyObject* Py_True
26
27 The Python ``True`` object. This object has no methods. It needs to be treated
28 just like any other object with respect to reference counts.
29
30
31.. cmacro:: Py_RETURN_FALSE
32
33 Return :const:`Py_False` from a function, properly incrementing its reference
34 count.
35
36
37.. cmacro:: Py_RETURN_TRUE
38
39 Return :const:`Py_True` from a function, properly incrementing its reference
40 count.
41
42
43.. cfunction:: PyObject* PyBool_FromLong(long v)
44
45 Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
46 truth value of *v*.