blob: fefc0033cceca197217b934ebef474dc598b39b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<span id="boolobjects"></span><h1>Boolean Objects</h1> <p>Booleans in Python are implemented as a subclass of integers. There are only two booleans, <a class="reference internal" href="#c.Py_False" title="Py_False"><code>Py_False</code></a> and <a class="reference internal" href="#c.Py_True" title="Py_True"><code>Py_True</code></a>. As such, the normal creation and deletion functions don’t apply to booleans. The following macros are available, however.</p> <dl class="c var"> <dt class="sig sig-object c" id="c.PyBool_Type">
<code>PyTypeObject PyBool_Type</code> </dt> <dd>
<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This instance of <a class="reference internal" href="type#c.PyTypeObject" title="PyTypeObject"><code>PyTypeObject</code></a> represents the Python boolean type; it is the same object as <a class="reference internal" href="../library/functions#bool" title="bool"><code>bool</code></a> in the Python layer.</p> </dd>
</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyBool_Check">
<code>int PyBool_Check(PyObject *o)</code> </dt> <dd>
<p>Return true if <em>o</em> is of type <a class="reference internal" href="#c.PyBool_Type" title="PyBool_Type"><code>PyBool_Type</code></a>. This function always succeeds.</p> </dd>
</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.Py_False">
<code>PyObject *Py_False</code> </dt> <dd>
<p>The Python <code>False</code> object. This object has no methods and is <a class="reference external" href="https://peps.python.org/pep-0683/">immortal</a>.</p> </dd>
</dl> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span><a class="reference internal" href="#c.Py_False" title="Py_False"><code>Py_False</code></a> is immortal.</p> </div> <dl class="c var"> <dt class="sig sig-object c" id="c.Py_True">
<code>PyObject *Py_True</code> </dt> <dd>
<p>The Python <code>True</code> object. This object has no methods and is <a class="reference external" href="https://peps.python.org/pep-0683/">immortal</a>.</p> </dd>
</dl> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span><a class="reference internal" href="#c.Py_True" title="Py_True"><code>Py_True</code></a> is immortal.</p> </div> <dl class="c macro"> <dt class="sig sig-object c" id="c.Py_RETURN_FALSE">
<code>Py_RETURN_FALSE</code> </dt> <dd>
<p>Return <a class="reference internal" href="#c.Py_False" title="Py_False"><code>Py_False</code></a> from a function.</p> </dd>
</dl> <dl class="c macro"> <dt class="sig sig-object c" id="c.Py_RETURN_TRUE">
<code>Py_RETURN_TRUE</code> </dt> <dd>
<p>Return <a class="reference internal" href="#c.Py_True" title="Py_True"><code>Py_True</code></a> from a function.</p> </dd>
</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyBool_FromLong">
<code>PyObject *PyBool_FromLong(long v)</code> </dt> <dd>
<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return <a class="reference internal" href="#c.Py_True" title="Py_True"><code>Py_True</code></a> or <a class="reference internal" href="#c.Py_False" title="Py_False"><code>Py_False</code></a>, depending on the truth value of <em>v</em>.</p> </dd>
</dl> <div class="_attribution">
<p class="_attribution-p">
© 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br>
<a href="https://docs.python.org/3.12/c-api/bool.html" class="_attribution-link">https://docs.python.org/3.12/c-api/bool.html</a>
</p>
</div>
|