~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.12-docs-html/c-api/bool.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>Boolean Objects &mdash; Python 2.7.12 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '2.7.12',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
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>
 
39
 
 
40
    
 
41
 
 
42
  </head>
 
43
  <body role="document">  
 
44
    <div class="related" role="navigation" aria-label="related navigation">
 
45
      <h3>Navigation</h3>
 
46
      <ul>
 
47
        <li class="right" style="margin-right: 10px">
 
48
          <a href="../genindex.html" title="General Index"
 
49
             accesskey="I">index</a></li>
 
50
        <li class="right" >
 
51
          <a href="../py-modindex.html" title="Python Module Index"
 
52
             >modules</a> |</li>
 
53
        <li class="right" >
 
54
          <a href="long.html" title="Long Integer Objects"
 
55
             accesskey="N">next</a> |</li>
 
56
        <li class="right" >
 
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> &raquo;</li>
 
62
        <li>
 
63
          <span class="version_switcher_placeholder">2.7.12</span>
 
64
          <a href="../index.html">Documentation</a> &raquo;
 
65
        </li>
 
66
 
 
67
          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &raquo;</li>
 
68
          <li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> &raquo;</li> 
 
69
      </ul>
 
70
    </div>    
 
71
 
 
72
    <div class="document">
 
73
      <div class="documentwrapper">
 
74
        <div class="bodywrapper">
 
75
          <div class="body" role="main">
 
76
            
 
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&#8217;t apply to booleans.  The following macros
 
82
are available, however.</p>
 
83
<dl class="function">
 
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>&nbsp;*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>
 
89
</div>
 
90
</dd></dl>
 
91
 
 
92
<dl class="var">
 
93
<dt id="c.Py_False">
 
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>
 
97
</dd></dl>
 
98
 
 
99
<dl class="var">
 
100
<dt id="c.Py_True">
 
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>
 
104
</dd></dl>
 
105
 
 
106
<dl class="macro">
 
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
 
110
count.</p>
 
111
<div class="versionadded">
 
112
<p><span class="versionmodified">New in version 2.4.</span></p>
 
113
</div>
 
114
</dd></dl>
 
115
 
 
116
<dl class="macro">
 
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
 
120
count.</p>
 
121
<div class="versionadded">
 
122
<p><span class="versionmodified">New in version 2.4.</span></p>
 
123
</div>
 
124
</dd></dl>
 
125
 
 
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>&nbsp;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>
 
133
</div>
 
134
</dd></dl>
 
135
 
 
136
</div>
 
137
 
 
138
 
 
139
          </div>
 
140
        </div>
 
141
      </div>
 
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>
 
147
  <h4>Next topic</h4>
 
148
  <p class="topless"><a href="long.html"
 
149
                        title="next chapter">Long Integer Objects</a></p>
 
150
<h3>This Page</h3>
 
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>
 
155
</ul>
 
156
 
 
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" />
 
164
    </form>
 
165
    <p class="searchtip" style="font-size: 90%">
 
166
    Enter search terms or a module, class or function name.
 
167
    </p>
 
168
</div>
 
169
<script type="text/javascript">$('#searchbox').show(0);</script>
 
170
        </div>
 
171
      </div>
 
172
      <div class="clearer"></div>
 
173
    </div>  
 
174
    <div class="related" role="navigation" aria-label="related navigation">
 
175
      <h3>Navigation</h3>
 
176
      <ul>
 
177
        <li class="right" style="margin-right: 10px">
 
178
          <a href="../genindex.html" title="General Index"
 
179
             >index</a></li>
 
180
        <li class="right" >
 
181
          <a href="../py-modindex.html" title="Python Module Index"
 
182
             >modules</a> |</li>
 
183
        <li class="right" >
 
184
          <a href="long.html" title="Long Integer Objects"
 
185
             >next</a> |</li>
 
186
        <li class="right" >
 
187
          <a href="int.html" title="Plain Integer Objects"
 
188
             >previous</a> |</li>
 
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> &raquo;</li>
 
192
        <li>
 
193
          <span class="version_switcher_placeholder">2.7.12</span>
 
194
          <a href="../index.html">Documentation</a> &raquo;
 
195
        </li>
 
196
 
 
197
          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &raquo;</li>
 
198
          <li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> &raquo;</li> 
 
199
      </ul>
 
200
    </div>  
 
201
    <div class="footer">
 
202
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
 
203
    <br />
 
204
    The Python Software Foundation is a non-profit corporation.
 
205
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
206
    <br />
 
207
    Last updated on Sep 20, 2016.
 
208
    <a href="../bugs.html">Found a bug</a>?
 
209
    <br />
 
210
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
211
    </div>
 
212
 
 
213
  </body>
 
214
</html>
 
 
b'\\ No newline at end of file'