1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>Boolean Objects — Python 2.7.12 documentation</title>
11
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/sidebar.js"></script>
27
<link rel="search" type="application/opensearchdescription+xml"
28
title="Search within Python 2.7.12 documentation"
29
href="../_static/opensearch.xml"/>
30
<link rel="author" title="About these documents" href="../about.html" />
31
<link rel="copyright" title="Copyright" href="../copyright.html" />
32
<link rel="top" title="Python 2.7.12 documentation" href="../contents.html" />
33
<link rel="up" title="Concrete Objects Layer" href="concrete.html" />
34
<link rel="next" title="Long Integer Objects" href="long.html" />
35
<link rel="prev" title="Plain Integer Objects" href="int.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="long.html" title="Long Integer Objects"
55
accesskey="N">next</a> |</li>
57
<a href="int.html" title="Plain Integer Objects"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">2.7.12</span>
64
<a href="../index.html">Documentation</a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
68
<li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="boolean-objects">
78
<span id="boolobjects"></span><h1>Boolean Objects<a class="headerlink" href="#boolean-objects" title="Permalink to this headline">¶</a></h1>
79
<p>Booleans in Python are implemented as a subclass of integers. There are only
80
two booleans, <code class="xref py py-const docutils literal"><span class="pre">Py_False</span></code> and <code class="xref py py-const docutils literal"><span class="pre">Py_True</span></code>. As such, the normal
81
creation and deletion functions don’t apply to booleans. The following macros
82
are available, however.</p>
84
<dt id="c.PyBool_Check">
85
int <code class="descname">PyBool_Check</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBool_Check" title="Permalink to this definition">¶</a></dt>
86
<dd><p>Return true if <em>o</em> is of type <code class="xref c c-data docutils literal"><span class="pre">PyBool_Type</span></code>.</p>
87
<div class="versionadded">
88
<p><span class="versionmodified">New in version 2.3.</span></p>
94
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">Py_False</code><a class="headerlink" href="#c.Py_False" title="Permalink to this definition">¶</a></dt>
95
<dd><p>The Python <code class="docutils literal"><span class="pre">False</span></code> object. This object has no methods. It needs to be
96
treated just like any other object with respect to reference counts.</p>
101
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">Py_True</code><a class="headerlink" href="#c.Py_True" title="Permalink to this definition">¶</a></dt>
102
<dd><p>The Python <code class="docutils literal"><span class="pre">True</span></code> object. This object has no methods. It needs to be treated
103
just like any other object with respect to reference counts.</p>
107
<dt id="c.Py_RETURN_FALSE">
108
<code class="descname">Py_RETURN_FALSE</code><a class="headerlink" href="#c.Py_RETURN_FALSE" title="Permalink to this definition">¶</a></dt>
109
<dd><p>Return <code class="xref py py-const docutils literal"><span class="pre">Py_False</span></code> from a function, properly incrementing its reference
111
<div class="versionadded">
112
<p><span class="versionmodified">New in version 2.4.</span></p>
117
<dt id="c.Py_RETURN_TRUE">
118
<code class="descname">Py_RETURN_TRUE</code><a class="headerlink" href="#c.Py_RETURN_TRUE" title="Permalink to this definition">¶</a></dt>
119
<dd><p>Return <code class="xref py py-const docutils literal"><span class="pre">Py_True</span></code> from a function, properly incrementing its reference
121
<div class="versionadded">
122
<p><span class="versionmodified">New in version 2.4.</span></p>
126
<dl class="function">
127
<dt id="c.PyBool_FromLong">
128
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyBool_FromLong</code><span class="sig-paren">(</span>long<em> v</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBool_FromLong" title="Permalink to this definition">¶</a></dt>
129
<dd><em class="refcount">Return value: New reference.</em><p>Return a new reference to <code class="xref py py-const docutils literal"><span class="pre">Py_True</span></code> or <code class="xref py py-const docutils literal"><span class="pre">Py_False</span></code> depending on the
130
truth value of <em>v</em>.</p>
131
<div class="versionadded">
132
<p><span class="versionmodified">New in version 2.3.</span></p>
142
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
143
<div class="sphinxsidebarwrapper">
144
<h4>Previous topic</h4>
145
<p class="topless"><a href="int.html"
146
title="previous chapter">Plain Integer Objects</a></p>
148
<p class="topless"><a href="long.html"
149
title="next chapter">Long Integer Objects</a></p>
151
<ul class="this-page-menu">
152
<li><a href="../bugs.html">Report a Bug</a></li>
153
<li><a href="../_sources/c-api/bool.txt"
154
rel="nofollow">Show Source</a></li>
157
<div id="searchbox" style="display: none" role="search">
158
<h3>Quick search</h3>
159
<form class="search" action="../search.html" method="get">
160
<input type="text" name="q" />
161
<input type="submit" value="Go" />
162
<input type="hidden" name="check_keywords" value="yes" />
163
<input type="hidden" name="area" value="default" />
165
<p class="searchtip" style="font-size: 90%">
166
Enter search terms or a module, class or function name.
169
<script type="text/javascript">$('#searchbox').show(0);</script>
172
<div class="clearer"></div>
174
<div class="related" role="navigation" aria-label="related navigation">
177
<li class="right" style="margin-right: 10px">
178
<a href="../genindex.html" title="General Index"
181
<a href="../py-modindex.html" title="Python Module Index"
184
<a href="long.html" title="Long Integer Objects"
187
<a href="int.html" title="Plain Integer Objects"
189
<li><img src="../_static/py.png" alt=""
190
style="vertical-align: middle; margin-top: -1px"/></li>
191
<li><a href="https://www.python.org/">Python</a> »</li>
193
<span class="version_switcher_placeholder">2.7.12</span>
194
<a href="../index.html">Documentation</a> »
197
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
198
<li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> »</li>
202
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
204
The Python Software Foundation is a non-profit corporation.
205
<a href="https://www.python.org/psf/donations/">Please donate.</a>
207
Last updated on Sep 20, 2016.
208
<a href="../bugs.html">Found a bug</a>?
210
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'