|  | <!DOCTYPE html>
<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="Built-in Constants" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/library/constants.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="A small number of constants live in the built-in namespace. They are: Constants added by the site module: The site module (which is imported automatically during startup, except if the-S command-li..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="A small number of constants live in the built-in namespace. They are: Constants added by the site module: The site module (which is imported automatically during startup, except if the-S command-li..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
    <title>Built-in Constants — Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
    
    <script src="../_static/documentation_options.js?v=2c828074"></script>
    <script src="../_static/doctools.js?v=888ff710"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <script src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.12.3 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="Built-in Types" href="stdtypes.html" />
    <link rel="prev" title="Built-in Functions" href="functions.html" />
    <link rel="canonical" href="https://docs.python.org/3/library/constants.html" />
    
      
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
    <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
            <script type="text/javascript" src="../_static/copybutton.js"></script>
            <script type="text/javascript" src="../_static/menu.js"></script>
            <script type="text/javascript" src="../_static/search-focus.js"></script>
            <script type="text/javascript" src="../_static/themetoggle.js"></script> 
  </head>
<body>
<div class="mobile-nav">
    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
    <nav class="nav-content" role="navigation">
        <label for="menuToggler" class="toggler__label">
            <span></span>
        </label>
        <span class="nav-items-wrapper">
            <a href="https://www.python.org/" class="nav-logo">
                <img src="../_static/py.svg" alt="Python logo"/>
            </a>
            <span class="version_switcher_placeholder"></span>
            <form role="search" class="search" action="../search.html" method="get">
                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
                </svg>
                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
                <input type="submit" value="Go"/>
            </form>
        </span>
    </nav>
    <div class="menu-wrapper">
        <nav class="menu" role="navigation" aria-label="main navigation">
            <div class="language_switcher_placeholder"></div>
            
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label>
  <div>
    <h3><a href="../contents.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">Built-in Constants</a><ul>
<li><a class="reference internal" href="#constants-added-by-the-site-module">Constants added by the <code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code> module</a></li>
</ul>
</li>
</ul>
  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="functions.html"
                          title="previous chapter">Built-in Functions</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="stdtypes.html"
                          title="next chapter">Built-in Types</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/main/Doc/library/constants.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </nav>
    </div>
</div>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="stdtypes.html" title="Built-in Types"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="functions.html" title="Built-in Functions"
             accesskey="P">previous</a> |</li>
          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> »</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.12.3 Documentation</a> »
    </li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Standard Library</a> »</li>
        <li class="nav-item nav-item-this"><a href="">Built-in Constants</a></li>
                <li class="right">
                    
    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
          <input type="submit" value="Go" />
        </form>
    </div>
                     |
                </li>
            <li class="right">
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label> |</li>
            
      </ul>
    </div>    
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="built-in-constants">
<span id="built-in-consts"></span><h1>Built-in Constants<a class="headerlink" href="#built-in-constants" title="Link to this heading">¶</a></h1>
<p>A small number of constants live in the built-in namespace.  They are:</p>
<dl class="py data">
<dt class="sig sig-object py" id="False">
<span class="sig-name descname"><span class="pre">False</span></span><a class="headerlink" href="#False" title="Link to this definition">¶</a></dt>
<dd><p>The false value of the <a class="reference internal" href="functions.html#bool" title="bool"><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></a> type. Assignments to <code class="docutils literal notranslate"><span class="pre">False</span></code>
are illegal and raise a <a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="True">
<span class="sig-name descname"><span class="pre">True</span></span><a class="headerlink" href="#True" title="Link to this definition">¶</a></dt>
<dd><p>The true value of the <a class="reference internal" href="functions.html#bool" title="bool"><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></a> type. Assignments to <code class="docutils literal notranslate"><span class="pre">True</span></code>
are illegal and raise a <a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="None">
<span class="sig-name descname"><span class="pre">None</span></span><a class="headerlink" href="#None" title="Link to this definition">¶</a></dt>
<dd><p>An object frequently used to represent the absence of a value, as when
default arguments are not passed to a function. Assignments to <code class="docutils literal notranslate"><span class="pre">None</span></code>
are illegal and raise a <a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.
<code class="docutils literal notranslate"><span class="pre">None</span></code> is the sole instance of the <a class="reference internal" href="types.html#types.NoneType" title="types.NoneType"><code class="xref py py-data docutils literal notranslate"><span class="pre">NoneType</span></code></a> type.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="NotImplemented">
<span class="sig-name descname"><span class="pre">NotImplemented</span></span><a class="headerlink" href="#NotImplemented" title="Link to this definition">¶</a></dt>
<dd><p>A special value which should be returned by the binary special methods
(e.g. <a class="reference internal" href="../reference/datamodel.html#object.__eq__" title="object.__eq__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__eq__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__lt__" title="object.__lt__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__lt__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__add__" title="object.__add__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__add__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__rsub__" title="object.__rsub__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__rsub__()</span></code></a>,
etc.) to indicate that the operation is not implemented with respect to
the other type; may be returned by the in-place binary special methods
(e.g. <a class="reference internal" href="../reference/datamodel.html#object.__imul__" title="object.__imul__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__imul__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__iand__" title="object.__iand__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__iand__()</span></code></a>, etc.) for the same purpose.
It should not be evaluated in a boolean context.
<code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> is the sole instance of the <a class="reference internal" href="types.html#types.NotImplementedType" title="types.NotImplementedType"><code class="xref py py-data docutils literal notranslate"><span class="pre">types.NotImplementedType</span></code></a> type.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When a binary (or in-place) method returns <code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> the
interpreter will try the reflected operation on the other type (or some
other fallback, depending on the operator).  If all attempts return
<code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code>, the interpreter will raise an appropriate exception.
Incorrectly returning <code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> will result in a misleading
error message or the <code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> value being returned to Python code.</p>
<p>See <a class="reference internal" href="numbers.html#implementing-the-arithmetic-operations"><span class="std std-ref">Implementing the arithmetic operations</span></a> for examples.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">NotImplementedError</span></code> and <code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> are not interchangeable,
even though they have similar names and purposes.
See <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotImplementedError</span></code></a> for details on when to use it.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.9: </span>Evaluating <code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code> in a boolean context is deprecated. While
it currently evaluates as true, it will emit a <a class="reference internal" href="exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>.
It will raise a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> in a future version of Python.</p>
</div>
</dd></dl>
<dl class="py data" id="index-0">
<dt class="sig sig-object py" id="Ellipsis">
<span class="sig-name descname"><span class="pre">Ellipsis</span></span><a class="headerlink" href="#Ellipsis" title="Link to this definition">¶</a></dt>
<dd><p>The same as the ellipsis literal “<code class="docutils literal notranslate"><span class="pre">...</span></code>”. Special value used mostly in conjunction
with extended slicing syntax for user-defined container data types.
<code class="docutils literal notranslate"><span class="pre">Ellipsis</span></code> is the sole instance of the <a class="reference internal" href="types.html#types.EllipsisType" title="types.EllipsisType"><code class="xref py py-data docutils literal notranslate"><span class="pre">types.EllipsisType</span></code></a> type.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="debug__">
<span class="sig-name descname"><span class="pre">__debug__</span></span><a class="headerlink" href="#debug__" title="Link to this definition">¶</a></dt>
<dd><p>This constant is true if Python was not started with an <a class="reference internal" href="../using/cmdline.html#cmdoption-O"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> option.
See also the <a class="reference internal" href="../reference/simple_stmts.html#assert"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">assert</span></code></a> statement.</p>
</dd></dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The names <a class="reference internal" href="#None" title="None"><code class="xref py py-data docutils literal notranslate"><span class="pre">None</span></code></a>, <a class="reference internal" href="#False" title="False"><code class="xref py py-data docutils literal notranslate"><span class="pre">False</span></code></a>, <a class="reference internal" href="#True" title="True"><code class="xref py py-data docutils literal notranslate"><span class="pre">True</span></code></a> and <a class="reference internal" href="#debug__" title="__debug__"><code class="xref py py-data docutils literal notranslate"><span class="pre">__debug__</span></code></a>
cannot be reassigned (assignments to them, even as an attribute name, raise
<a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>), so they can be considered “true” constants.</p>
</div>
<section id="constants-added-by-the-site-module">
<h2>Constants added by the <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module<a class="headerlink" href="#constants-added-by-the-site-module" title="Link to this heading">¶</a></h2>
<p>The <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module (which is imported automatically during startup, except
if the <a class="reference internal" href="../using/cmdline.html#cmdoption-S"><code class="xref std std-option docutils literal notranslate"><span class="pre">-S</span></code></a> command-line option is given) adds several constants to the
built-in namespace.  They are useful for the interactive interpreter shell and
should not be used in programs.</p>
<dl class="py data">
<dt class="sig sig-object py" id="quit">
<span class="sig-name descname"><span class="pre">quit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quit" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="exit">
<span class="sig-name descname"><span class="pre">exit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#exit" title="Link to this definition">¶</a></dt>
<dd><p>Objects that when printed, print a message like “Use quit() or Ctrl-D
(i.e. EOF) to exit”, and when called, raise <a class="reference internal" href="exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> with the
specified exit code.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="copyright">
<span class="sig-name descname"><span class="pre">copyright</span></span><a class="headerlink" href="#copyright" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="credits">
<span class="sig-name descname"><span class="pre">credits</span></span><a class="headerlink" href="#credits" title="Link to this definition">¶</a></dt>
<dd><p>Objects that when printed or called, print the text of copyright or
credits, respectively.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="license">
<span class="sig-name descname"><span class="pre">license</span></span><a class="headerlink" href="#license" title="Link to this definition">¶</a></dt>
<dd><p>Object that when printed, prints the message “Type license() to see the
full license text”, and when called, displays the full license text in a
pager-like fashion (one screen at a time).</p>
</dd></dl>
</section>
</section>
            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3><a href="../contents.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">Built-in Constants</a><ul>
<li><a class="reference internal" href="#constants-added-by-the-site-module">Constants added by the <code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code> module</a></li>
</ul>
</li>
</ul>
  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="functions.html"
                          title="previous chapter">Built-in Functions</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="stdtypes.html"
                          title="next chapter">Built-in Types</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/main/Doc/library/constants.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="stdtypes.html" title="Built-in Types"
             >next</a> |</li>
        <li class="right" >
          <a href="functions.html" title="Built-in Functions"
             >previous</a> |</li>
          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> »</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.12.3 Documentation</a> »
    </li>
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
        <li class="nav-item nav-item-this"><a href="">Built-in Constants</a></li>
                <li class="right">
                    
    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
          <input type="submit" value="Go" />
        </form>
    </div>
                     |
                </li>
            <li class="right">
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label> |</li>
            
      </ul>
    </div>  
    <div class="footer">
    © 
      <a href="../copyright.html">
    
    Copyright
    
      </a>
     2001-2024, Python Software Foundation.
    <br />
    This page is licensed under the Python Software Foundation License Version 2.
    <br />
    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
    <br />
    
      See <a href="/license.html">History and License</a> for more information.<br />
    
    
    <br />
    The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
    <br />
      Last updated on Apr 09, 2024 (13:47 UTC).
    
      <a href="/bugs.html">Found a bug</a>?
    
    <br />
    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
    </div>
  </body>
</html>
 |