PageRenderTime 336ms CodeModel.GetById 201ms app.highlight 2ms RepoModel.GetById 129ms app.codeStats 0ms

/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
 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   .. versionadded:: 2.3
19
20
21.. cvar:: PyObject* Py_False
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
27.. cvar:: PyObject* Py_True
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
33.. cmacro:: Py_RETURN_FALSE
34
35   Return :const:`Py_False` from a function, properly incrementing its reference
36   count.
37
38   .. versionadded:: 2.4
39
40
41.. cmacro:: Py_RETURN_TRUE
42
43   Return :const:`Py_True` from a function, properly incrementing its reference
44   count.
45
46   .. versionadded:: 2.4
47
48
49.. cfunction:: PyObject* PyBool_FromLong(long v)
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