gooderp18绿色标准版
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1369 rindas
156KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="./">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="Glossary" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/glossary.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content=">>>, The default Python prompt of the interactive shell. Often seen for code examples which can be executed interactively in the interpreter.,,..., Can refer to:- The default Python prompt of the i..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content=">>>, The default Python prompt of the interactive shell. Often seen for code examples which can be executed interactively in the interpreter.,,..., Can refer to:- The default Python prompt of the i..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>Glossary &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="_static/documentation_options.js?v=2c828074"></script>
  22. <script src="_static/doctools.js?v=888ff710"></script>
  23. <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="about.html" />
  29. <link rel="index" title="Index" href="genindex.html" />
  30. <link rel="search" title="Search" href="search.html" />
  31. <link rel="copyright" title="Copyright" href="copyright.html" />
  32. <link rel="next" title="About these documents" href="about.html" />
  33. <link rel="prev" title="“Why is Python Installed on my Computer?” FAQ" href="faq/installed.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/glossary.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="_static/py.svg" />
  44. <script type="text/javascript" src="_static/copybutton.js"></script>
  45. <script type="text/javascript" src="_static/menu.js"></script>
  46. <script type="text/javascript" src="_static/search-focus.js"></script>
  47. <script type="text/javascript" src="_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <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>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h4>Previous topic</h4>
  84. <p class="topless"><a href="faq/installed.html"
  85. title="previous chapter">“Why is Python Installed on my Computer?” FAQ</a></p>
  86. </div>
  87. <div>
  88. <h4>Next topic</h4>
  89. <p class="topless"><a href="about.html"
  90. title="next chapter">About these documents</a></p>
  91. </div>
  92. <div role="note" aria-label="source link">
  93. <h3>This Page</h3>
  94. <ul class="this-page-menu">
  95. <li><a href="bugs.html">Report a Bug</a></li>
  96. <li>
  97. <a href="https://github.com/python/cpython/blob/main/Doc/glossary.rst"
  98. rel="nofollow">Show Source
  99. </a>
  100. </li>
  101. </ul>
  102. </div>
  103. </nav>
  104. </div>
  105. </div>
  106. <div class="related" role="navigation" aria-label="related navigation">
  107. <h3>Navigation</h3>
  108. <ul>
  109. <li class="right" style="margin-right: 10px">
  110. <a href="genindex.html" title="General Index"
  111. accesskey="I">index</a></li>
  112. <li class="right" >
  113. <a href="py-modindex.html" title="Python Module Index"
  114. >modules</a> |</li>
  115. <li class="right" >
  116. <a href="about.html" title="About these documents"
  117. accesskey="N">next</a> |</li>
  118. <li class="right" >
  119. <a href="faq/installed.html" title="“Why is Python Installed on my Computer?” FAQ"
  120. accesskey="P">previous</a> |</li>
  121. <li><img src="_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  122. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  123. <li class="switchers">
  124. <div class="language_switcher_placeholder"></div>
  125. <div class="version_switcher_placeholder"></div>
  126. </li>
  127. <li>
  128. </li>
  129. <li id="cpython-language-and-version">
  130. <a href="index.html">3.12.3 Documentation</a> &#187;
  131. </li>
  132. <li class="nav-item nav-item-this"><a href="">Glossary</a></li>
  133. <li class="right">
  134. <div class="inline-search" role="search">
  135. <form class="inline-search" action="search.html" method="get">
  136. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  137. <input type="submit" value="Go" />
  138. </form>
  139. </div>
  140. |
  141. </li>
  142. <li class="right">
  143. <label class="theme-selector-label">
  144. Theme
  145. <select class="theme-selector" oninput="activateTheme(this.value)">
  146. <option value="auto" selected>Auto</option>
  147. <option value="light">Light</option>
  148. <option value="dark">Dark</option>
  149. </select>
  150. </label> |</li>
  151. </ul>
  152. </div>
  153. <div class="document">
  154. <div class="documentwrapper">
  155. <div class="bodywrapper">
  156. <div class="body" role="main">
  157. <section id="glossary">
  158. <span id="id1"></span><h1>Glossary<a class="headerlink" href="#glossary" title="Link to this heading">¶</a></h1>
  159. <dl class="glossary">
  160. <dt id="term-0"><code class="docutils literal notranslate"><span class="pre">&gt;&gt;&gt;</span></code><a class="headerlink" href="#term-0" title="Link to this term">¶</a></dt><dd><p>The default Python prompt of the interactive shell. Often seen for code
  161. examples which can be executed interactively in the interpreter.</p>
  162. </dd>
  163. <dt id="term-..."><code class="docutils literal notranslate"><span class="pre">...</span></code><a class="headerlink" href="#term-..." title="Link to this term">¶</a></dt><dd><p>Can refer to:</p>
  164. <ul class="simple">
  165. <li><p>The default Python prompt of the interactive shell when entering the
  166. code for an indented code block, when within a pair of matching left and
  167. right delimiters (parentheses, square brackets, curly braces or triple
  168. quotes), or after specifying a decorator.</p></li>
  169. <li><p>The <a class="reference internal" href="library/constants.html#Ellipsis" title="Ellipsis"><code class="xref py py-const docutils literal notranslate"><span class="pre">Ellipsis</span></code></a> built-in constant.</p></li>
  170. </ul>
  171. </dd>
  172. <dt id="term-2to3">2to3<a class="headerlink" href="#term-2to3" title="Link to this term">¶</a></dt><dd><p>A tool that tries to convert Python 2.x code to Python 3.x code by
  173. handling most of the incompatibilities which can be detected by parsing the
  174. source and traversing the parse tree.</p>
  175. <p>2to3 is available in the standard library as <a class="reference internal" href="library/2to3.html#module-lib2to3" title="lib2to3: The 2to3 library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code></a>; a standalone
  176. entry point is provided as <code class="file docutils literal notranslate"><span class="pre">Tools/scripts/2to3</span></code>. See
  177. <a class="reference internal" href="library/2to3.html#to3-reference"><span class="std std-ref">2to3 — Automated Python 2 to 3 code translation</span></a>.</p>
  178. </dd>
  179. <dt id="term-abstract-base-class">abstract base class<a class="headerlink" href="#term-abstract-base-class" title="Link to this term">¶</a></dt><dd><p>Abstract base classes complement <a class="reference internal" href="#term-duck-typing"><span class="xref std std-term">duck-typing</span></a> by
  180. providing a way to define interfaces when other techniques like
  181. <a class="reference internal" href="library/functions.html#hasattr" title="hasattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">hasattr()</span></code></a> would be clumsy or subtly wrong (for example with
  182. <a class="reference internal" href="reference/datamodel.html#special-lookup"><span class="std std-ref">magic methods</span></a>). ABCs introduce virtual
  183. subclasses, which are classes that don’t inherit from a class but are
  184. still recognized by <a class="reference internal" href="library/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> and <a class="reference internal" href="library/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a>; see the
  185. <a class="reference internal" href="library/abc.html#module-abc" title="abc: Abstract base classes according to :pep:`3119`."><code class="xref py py-mod docutils literal notranslate"><span class="pre">abc</span></code></a> module documentation. Python comes with many built-in ABCs for
  186. data structures (in the <a class="reference internal" href="library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code></a> module), numbers (in the
  187. <a class="reference internal" href="library/numbers.html#module-numbers" title="numbers: Numeric abstract base classes (Complex, Real, Integral, etc.)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">numbers</span></code></a> module), streams (in the <a class="reference internal" href="library/io.html#module-io" title="io: Core tools for working with streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">io</span></code></a> module), import finders
  188. and loaders (in the <a class="reference internal" href="library/importlib.html#module-importlib.abc" title="importlib.abc: Abstract base classes related to import"><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib.abc</span></code></a> module). You can create your own
  189. ABCs with the <a class="reference internal" href="library/abc.html#module-abc" title="abc: Abstract base classes according to :pep:`3119`."><code class="xref py py-mod docutils literal notranslate"><span class="pre">abc</span></code></a> module.</p>
  190. </dd>
  191. <dt id="term-annotation">annotation<a class="headerlink" href="#term-annotation" title="Link to this term">¶</a></dt><dd><p>A label associated with a variable, a class
  192. attribute or a function parameter or return value,
  193. used by convention as a <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hint</span></a>.</p>
  194. <p>Annotations of local variables cannot be accessed at runtime, but
  195. annotations of global variables, class attributes, and functions
  196. are stored in the <code class="xref py py-attr docutils literal notranslate"><span class="pre">__annotations__</span></code>
  197. special attribute of modules, classes, and functions,
  198. respectively.</p>
  199. <p>See <a class="reference internal" href="#term-variable-annotation"><span class="xref std std-term">variable annotation</span></a>, <a class="reference internal" href="#term-function-annotation"><span class="xref std std-term">function annotation</span></a>, <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>
  200. and <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0526/"><strong>PEP 526</strong></a>, which describe this functionality.
  201. Also see <a class="reference internal" href="howto/annotations.html#annotations-howto"><span class="std std-ref">Annotations Best Practices</span></a>
  202. for best practices on working with annotations.</p>
  203. </dd>
  204. <dt id="term-argument">argument<a class="headerlink" href="#term-argument" title="Link to this term">¶</a></dt><dd><p>A value passed to a <a class="reference internal" href="#term-function"><span class="xref std std-term">function</span></a> (or <a class="reference internal" href="#term-method"><span class="xref std std-term">method</span></a>) when calling the
  205. function. There are two kinds of argument:</p>
  206. <ul>
  207. <li><p><em class="dfn">keyword argument</em>: an argument preceded by an identifier (e.g.
  208. <code class="docutils literal notranslate"><span class="pre">name=</span></code>) in a function call or passed as a value in a dictionary
  209. preceded by <code class="docutils literal notranslate"><span class="pre">**</span></code>. For example, <code class="docutils literal notranslate"><span class="pre">3</span></code> and <code class="docutils literal notranslate"><span class="pre">5</span></code> are both keyword
  210. arguments in the following calls to <a class="reference internal" href="library/functions.html#complex" title="complex"><code class="xref py py-func docutils literal notranslate"><span class="pre">complex()</span></code></a>:</p>
  211. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">complex</span><span class="p">(</span><span class="n">real</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">imag</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  212. <span class="nb">complex</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s1">&#39;real&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">&#39;imag&#39;</span><span class="p">:</span> <span class="mi">5</span><span class="p">})</span>
  213. </pre></div>
  214. </div>
  215. </li>
  216. <li><p><em class="dfn">positional argument</em>: an argument that is not a keyword argument.
  217. Positional arguments can appear at the beginning of an argument list
  218. and/or be passed as elements of an <a class="reference internal" href="#term-iterable"><span class="xref std std-term">iterable</span></a> preceded by <code class="docutils literal notranslate"><span class="pre">*</span></code>.
  219. For example, <code class="docutils literal notranslate"><span class="pre">3</span></code> and <code class="docutils literal notranslate"><span class="pre">5</span></code> are both positional arguments in the
  220. following calls:</p>
  221. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">complex</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
  222. <span class="nb">complex</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
  223. </pre></div>
  224. </div>
  225. </li>
  226. </ul>
  227. <p>Arguments are assigned to the named local variables in a function body.
  228. See the <a class="reference internal" href="reference/expressions.html#calls"><span class="std std-ref">Calls</span></a> section for the rules governing this assignment.
  229. Syntactically, any expression can be used to represent an argument; the
  230. evaluated value is assigned to the local variable.</p>
  231. <p>See also the <a class="reference internal" href="#term-parameter"><span class="xref std std-term">parameter</span></a> glossary entry, the FAQ question on
  232. <a class="reference internal" href="faq/programming.html#faq-argument-vs-parameter"><span class="std std-ref">the difference between arguments and parameters</span></a>, and <span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0362/"><strong>PEP 362</strong></a>.</p>
  233. </dd>
  234. <dt id="term-asynchronous-context-manager">asynchronous context manager<a class="headerlink" href="#term-asynchronous-context-manager" title="Link to this term">¶</a></dt><dd><p>An object which controls the environment seen in an
  235. <a class="reference internal" href="reference/compound_stmts.html#async-with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">with</span></code></a> statement by defining <a class="reference internal" href="reference/datamodel.html#object.__aenter__" title="object.__aenter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__aenter__()</span></code></a> and
  236. <a class="reference internal" href="reference/datamodel.html#object.__aexit__" title="object.__aexit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__aexit__()</span></code></a> methods. Introduced by <span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  237. </dd>
  238. <dt id="term-asynchronous-generator">asynchronous generator<a class="headerlink" href="#term-asynchronous-generator" title="Link to this term">¶</a></dt><dd><p>A function which returns an <a class="reference internal" href="#term-asynchronous-generator-iterator"><span class="xref std std-term">asynchronous generator iterator</span></a>. It
  239. looks like a coroutine function defined with <a class="reference internal" href="reference/compound_stmts.html#async-def"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">def</span></code></a> except
  240. that it contains <a class="reference internal" href="reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> expressions for producing a series of
  241. values usable in an <a class="reference internal" href="reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a> loop.</p>
  242. <p>Usually refers to an asynchronous generator function, but may refer to an
  243. <em>asynchronous generator iterator</em> in some contexts. In cases where the
  244. intended meaning isn’t clear, using the full terms avoids ambiguity.</p>
  245. <p>An asynchronous generator function may contain <a class="reference internal" href="reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a>
  246. expressions as well as <a class="reference internal" href="reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a>, and <a class="reference internal" href="reference/compound_stmts.html#async-with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">with</span></code></a>
  247. statements.</p>
  248. </dd>
  249. <dt id="term-asynchronous-generator-iterator">asynchronous generator iterator<a class="headerlink" href="#term-asynchronous-generator-iterator" title="Link to this term">¶</a></dt><dd><p>An object created by a <a class="reference internal" href="#term-asynchronous-generator"><span class="xref std std-term">asynchronous generator</span></a> function.</p>
  250. <p>This is an <a class="reference internal" href="#term-asynchronous-iterator"><span class="xref std std-term">asynchronous iterator</span></a> which when called using the
  251. <a class="reference internal" href="reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a> method returns an awaitable object which will execute
  252. the body of the asynchronous generator function until the next
  253. <a class="reference internal" href="reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> expression.</p>
  254. <p>Each <a class="reference internal" href="reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> temporarily suspends processing, remembering the
  255. location execution state (including local variables and pending
  256. try-statements). When the <em>asynchronous generator iterator</em> effectively
  257. resumes with another awaitable returned by <a class="reference internal" href="reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a>, it
  258. picks up where it left off. See <span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a> and <span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-0525/"><strong>PEP 525</strong></a>.</p>
  259. </dd>
  260. <dt id="term-asynchronous-iterable">asynchronous iterable<a class="headerlink" href="#term-asynchronous-iterable" title="Link to this term">¶</a></dt><dd><p>An object, that can be used in an <a class="reference internal" href="reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a> statement.
  261. Must return an <a class="reference internal" href="#term-asynchronous-iterator"><span class="xref std std-term">asynchronous iterator</span></a> from its
  262. <a class="reference internal" href="reference/datamodel.html#object.__aiter__" title="object.__aiter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__aiter__()</span></code></a> method. Introduced by <span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  263. </dd>
  264. <dt id="term-asynchronous-iterator">asynchronous iterator<a class="headerlink" href="#term-asynchronous-iterator" title="Link to this term">¶</a></dt><dd><p>An object that implements the <a class="reference internal" href="reference/datamodel.html#object.__aiter__" title="object.__aiter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__aiter__()</span></code></a> and <a class="reference internal" href="reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a>
  265. methods. <a class="reference internal" href="reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a> must return an <a class="reference internal" href="#term-awaitable"><span class="xref std std-term">awaitable</span></a> object.
  266. <a class="reference internal" href="reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a> resolves the awaitables returned by an asynchronous
  267. iterator’s <a class="reference internal" href="reference/datamodel.html#object.__anext__" title="object.__anext__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__anext__()</span></code></a> method until it raises a
  268. <a class="reference internal" href="library/exceptions.html#StopAsyncIteration" title="StopAsyncIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopAsyncIteration</span></code></a> exception. Introduced by <span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  269. </dd>
  270. <dt id="term-attribute">attribute<a class="headerlink" href="#term-attribute" title="Link to this term">¶</a></dt><dd><p>A value associated with an object which is usually referenced by name
  271. using dotted expressions.
  272. For example, if an object <em>o</em> has an attribute
  273. <em>a</em> it would be referenced as <em>o.a</em>.</p>
  274. <p>It is possible to give an object an attribute whose name is not an
  275. identifier as defined by <a class="reference internal" href="reference/lexical_analysis.html#identifiers"><span class="std std-ref">Identifiers and keywords</span></a>, for example using
  276. <a class="reference internal" href="library/functions.html#setattr" title="setattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">setattr()</span></code></a>, if the object allows it.
  277. Such an attribute will not be accessible using a dotted expression,
  278. and would instead need to be retrieved with <a class="reference internal" href="library/functions.html#getattr" title="getattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">getattr()</span></code></a>.</p>
  279. </dd>
  280. <dt id="term-awaitable">awaitable<a class="headerlink" href="#term-awaitable" title="Link to this term">¶</a></dt><dd><p>An object that can be used in an <a class="reference internal" href="reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> expression. Can be
  281. a <a class="reference internal" href="#term-coroutine"><span class="xref std std-term">coroutine</span></a> or an object with an <a class="reference internal" href="reference/datamodel.html#object.__await__" title="object.__await__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__await__()</span></code></a> method.
  282. See also <span class="target" id="index-8"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  283. </dd>
  284. <dt id="term-BDFL">BDFL<a class="headerlink" href="#term-BDFL" title="Link to this term">¶</a></dt><dd><p>Benevolent Dictator For Life, a.k.a. <a class="reference external" href="https://gvanrossum.github.io/">Guido van Rossum</a>, Python’s creator.</p>
  285. </dd>
  286. <dt id="term-binary-file">binary file<a class="headerlink" href="#term-binary-file" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="#term-file-object"><span class="xref std std-term">file object</span></a> able to read and write
  287. <a class="reference internal" href="#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a>.
  288. Examples of binary files are files opened in binary mode (<code class="docutils literal notranslate"><span class="pre">'rb'</span></code>,
  289. <code class="docutils literal notranslate"><span class="pre">'wb'</span></code> or <code class="docutils literal notranslate"><span class="pre">'rb+'</span></code>), <a class="reference internal" href="library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin.buffer</span></code></a>,
  290. <a class="reference internal" href="library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout.buffer</span></code></a>, and instances of
  291. <a class="reference internal" href="library/io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> and <a class="reference internal" href="library/gzip.html#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">gzip.GzipFile</span></code></a>.</p>
  292. <p>See also <a class="reference internal" href="#term-text-file"><span class="xref std std-term">text file</span></a> for a file object able to read and write
  293. <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> objects.</p>
  294. </dd>
  295. <dt id="term-borrowed-reference">borrowed reference<a class="headerlink" href="#term-borrowed-reference" title="Link to this term">¶</a></dt><dd><p>In Python’s C API, a borrowed reference is a reference to an object,
  296. where the code using the object does not own the reference.
  297. It becomes a dangling
  298. pointer if the object is destroyed. For example, a garbage collection can
  299. remove the last <a class="reference internal" href="#term-strong-reference"><span class="xref std std-term">strong reference</span></a> to the object and so destroy it.</p>
  300. <p>Calling <a class="reference internal" href="c-api/refcounting.html#c.Py_INCREF" title="Py_INCREF"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_INCREF()</span></code></a> on the <a class="reference internal" href="#term-borrowed-reference"><span class="xref std std-term">borrowed reference</span></a> is
  301. recommended to convert it to a <a class="reference internal" href="#term-strong-reference"><span class="xref std std-term">strong reference</span></a> in-place, except
  302. when the object cannot be destroyed before the last usage of the borrowed
  303. reference. The <a class="reference internal" href="c-api/refcounting.html#c.Py_NewRef" title="Py_NewRef"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_NewRef()</span></code></a> function can be used to create a new
  304. <a class="reference internal" href="#term-strong-reference"><span class="xref std std-term">strong reference</span></a>.</p>
  305. </dd>
  306. <dt id="term-bytes-like-object">bytes-like object<a class="headerlink" href="#term-bytes-like-object" title="Link to this term">¶</a></dt><dd><p>An object that supports the <a class="reference internal" href="c-api/buffer.html#bufferobjects"><span class="std std-ref">Buffer Protocol</span></a> and can
  307. export a C-<a class="reference internal" href="#term-contiguous"><span class="xref std std-term">contiguous</span></a> buffer. This includes all <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>,
  308. <a class="reference internal" href="library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>, and <a class="reference internal" href="library/array.html#array.array" title="array.array"><code class="xref py py-class docutils literal notranslate"><span class="pre">array.array</span></code></a> objects, as well as many
  309. common <a class="reference internal" href="library/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a> objects. Bytes-like objects can
  310. be used for various operations that work with binary data; these include
  311. compression, saving to a binary file, and sending over a socket.</p>
  312. <p>Some operations need the binary data to be mutable. The documentation
  313. often refers to these as “read-write bytes-like objects”. Example
  314. mutable buffer objects include <a class="reference internal" href="library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> and a
  315. <a class="reference internal" href="library/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a> of a <a class="reference internal" href="library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>.
  316. Other operations require the binary data to be stored in
  317. immutable objects (“read-only bytes-like objects”); examples
  318. of these include <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and a <a class="reference internal" href="library/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a>
  319. of a <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object.</p>
  320. </dd>
  321. <dt id="term-bytecode">bytecode<a class="headerlink" href="#term-bytecode" title="Link to this term">¶</a></dt><dd><p>Python source code is compiled into bytecode, the internal representation
  322. of a Python program in the CPython interpreter. The bytecode is also
  323. cached in <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files so that executing the same file is
  324. faster the second time (recompilation from source to bytecode can be
  325. avoided). This “intermediate language” is said to run on a
  326. <a class="reference internal" href="#term-virtual-machine"><span class="xref std std-term">virtual machine</span></a> that executes the machine code corresponding to
  327. each bytecode. Do note that bytecodes are not expected to work between
  328. different Python virtual machines, nor to be stable between Python
  329. releases.</p>
  330. <p>A list of bytecode instructions can be found in the documentation for
  331. <a class="reference internal" href="library/dis.html#bytecodes"><span class="std std-ref">the dis module</span></a>.</p>
  332. </dd>
  333. <dt id="term-callable">callable<a class="headerlink" href="#term-callable" title="Link to this term">¶</a></dt><dd><p>A callable is an object that can be called, possibly with a set
  334. of arguments (see <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a>), with the following syntax:</p>
  335. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">callable</span><span class="p">(</span><span class="n">argument1</span><span class="p">,</span> <span class="n">argument2</span><span class="p">,</span> <span class="n">argumentN</span><span class="p">)</span>
  336. </pre></div>
  337. </div>
  338. <p>A <a class="reference internal" href="#term-function"><span class="xref std std-term">function</span></a>, and by extension a <a class="reference internal" href="#term-method"><span class="xref std std-term">method</span></a>, is a callable.
  339. An instance of a class that implements the <a class="reference internal" href="reference/datamodel.html#object.__call__" title="object.__call__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__call__()</span></code></a>
  340. method is also a callable.</p>
  341. </dd>
  342. <dt id="term-callback">callback<a class="headerlink" href="#term-callback" title="Link to this term">¶</a></dt><dd><p>A subroutine function which is passed as an argument to be executed at
  343. some point in the future.</p>
  344. </dd>
  345. <dt id="term-class">class<a class="headerlink" href="#term-class" title="Link to this term">¶</a></dt><dd><p>A template for creating user-defined objects. Class definitions
  346. normally contain method definitions which operate on instances of the
  347. class.</p>
  348. </dd>
  349. <dt id="term-class-variable">class variable<a class="headerlink" href="#term-class-variable" title="Link to this term">¶</a></dt><dd><p>A variable defined in a class and intended to be modified only at
  350. class level (i.e., not in an instance of the class).</p>
  351. </dd>
  352. <dt id="term-complex-number">complex number<a class="headerlink" href="#term-complex-number" title="Link to this term">¶</a></dt><dd><p>An extension of the familiar real number system in which all numbers are
  353. expressed as a sum of a real part and an imaginary part. Imaginary
  354. numbers are real multiples of the imaginary unit (the square root of
  355. <code class="docutils literal notranslate"><span class="pre">-1</span></code>), often written <code class="docutils literal notranslate"><span class="pre">i</span></code> in mathematics or <code class="docutils literal notranslate"><span class="pre">j</span></code> in
  356. engineering. Python has built-in support for complex numbers, which are
  357. written with this latter notation; the imaginary part is written with a
  358. <code class="docutils literal notranslate"><span class="pre">j</span></code> suffix, e.g., <code class="docutils literal notranslate"><span class="pre">3+1j</span></code>. To get access to complex equivalents of the
  359. <a class="reference internal" href="library/math.html#module-math" title="math: Mathematical functions (sin() etc.)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">math</span></code></a> module, use <a class="reference internal" href="library/cmath.html#module-cmath" title="cmath: Mathematical functions for complex numbers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">cmath</span></code></a>. Use of complex numbers is a fairly
  360. advanced mathematical feature. If you’re not aware of a need for them,
  361. it’s almost certain you can safely ignore them.</p>
  362. </dd>
  363. <dt id="term-context-manager">context manager<a class="headerlink" href="#term-context-manager" title="Link to this term">¶</a></dt><dd><p>An object which controls the environment seen in a <a class="reference internal" href="reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a>
  364. statement by defining <a class="reference internal" href="reference/datamodel.html#object.__enter__" title="object.__enter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__enter__()</span></code></a> and <a class="reference internal" href="reference/datamodel.html#object.__exit__" title="object.__exit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code></a> methods.
  365. See <span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0343/"><strong>PEP 343</strong></a>.</p>
  366. </dd>
  367. <dt id="term-context-variable">context variable<a class="headerlink" href="#term-context-variable" title="Link to this term">¶</a></dt><dd><p>A variable which can have different values depending on its context.
  368. This is similar to Thread-Local Storage in which each execution
  369. thread may have a different value for a variable. However, with context
  370. variables, there may be several contexts in one execution thread and the
  371. main usage for context variables is to keep track of variables in
  372. concurrent asynchronous tasks.
  373. See <a class="reference internal" href="library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a>.</p>
  374. </dd>
  375. <dt id="term-contiguous">contiguous<a class="headerlink" href="#term-contiguous" title="Link to this term">¶</a></dt><dd><p id="index-10">A buffer is considered contiguous exactly if it is either
  376. <em>C-contiguous</em> or <em>Fortran contiguous</em>. Zero-dimensional buffers are
  377. C and Fortran contiguous. In one-dimensional arrays, the items
  378. must be laid out in memory next to each other, in order of
  379. increasing indexes starting from zero. In multidimensional
  380. C-contiguous arrays, the last index varies the fastest when
  381. visiting items in order of memory address. However, in
  382. Fortran contiguous arrays, the first index varies the fastest.</p>
  383. </dd>
  384. <dt id="term-coroutine">coroutine<a class="headerlink" href="#term-coroutine" title="Link to this term">¶</a></dt><dd><p>Coroutines are a more generalized form of subroutines. Subroutines are
  385. entered at one point and exited at another point. Coroutines can be
  386. entered, exited, and resumed at many different points. They can be
  387. implemented with the <a class="reference internal" href="reference/compound_stmts.html#async-def"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">def</span></code></a> statement. See also
  388. <span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  389. </dd>
  390. <dt id="term-coroutine-function">coroutine function<a class="headerlink" href="#term-coroutine-function" title="Link to this term">¶</a></dt><dd><p>A function which returns a <a class="reference internal" href="#term-coroutine"><span class="xref std std-term">coroutine</span></a> object. A coroutine
  391. function may be defined with the <a class="reference internal" href="reference/compound_stmts.html#async-def"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">def</span></code></a> statement,
  392. and may contain <a class="reference internal" href="reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a>, <a class="reference internal" href="reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a>, and
  393. <a class="reference internal" href="reference/compound_stmts.html#async-with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">with</span></code></a> keywords. These were introduced
  394. by <span class="target" id="index-12"></span><a class="pep reference external" href="https://peps.python.org/pep-0492/"><strong>PEP 492</strong></a>.</p>
  395. </dd>
  396. <dt id="term-CPython">CPython<a class="headerlink" href="#term-CPython" title="Link to this term">¶</a></dt><dd><p>The canonical implementation of the Python programming language, as
  397. distributed on <a class="reference external" href="https://www.python.org">python.org</a>. The term “CPython”
  398. is used when necessary to distinguish this implementation from others
  399. such as Jython or IronPython.</p>
  400. </dd>
  401. <dt id="term-decorator">decorator<a class="headerlink" href="#term-decorator" title="Link to this term">¶</a></dt><dd><p>A function returning another function, usually applied as a function
  402. transformation using the <code class="docutils literal notranslate"><span class="pre">&#64;wrapper</span></code> syntax. Common examples for
  403. decorators are <a class="reference internal" href="library/functions.html#classmethod" title="classmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">classmethod()</span></code></a> and <a class="reference internal" href="library/functions.html#staticmethod" title="staticmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">staticmethod()</span></code></a>.</p>
  404. <p>The decorator syntax is merely syntactic sugar, the following two
  405. function definitions are semantically equivalent:</p>
  406. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">arg</span><span class="p">):</span>
  407. <span class="o">...</span>
  408. <span class="n">f</span> <span class="o">=</span> <span class="nb">staticmethod</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
  409. <span class="nd">@staticmethod</span>
  410. <span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">arg</span><span class="p">):</span>
  411. <span class="o">...</span>
  412. </pre></div>
  413. </div>
  414. <p>The same concept exists for classes, but is less commonly used there. See
  415. the documentation for <a class="reference internal" href="reference/compound_stmts.html#function"><span class="std std-ref">function definitions</span></a> and
  416. <a class="reference internal" href="reference/compound_stmts.html#class"><span class="std std-ref">class definitions</span></a> for more about decorators.</p>
  417. </dd>
  418. <dt id="term-descriptor">descriptor<a class="headerlink" href="#term-descriptor" title="Link to this term">¶</a></dt><dd><p>Any object which defines the methods <a class="reference internal" href="reference/datamodel.html#object.__get__" title="object.__get__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__get__()</span></code></a>,
  419. <a class="reference internal" href="reference/datamodel.html#object.__set__" title="object.__set__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__set__()</span></code></a>, or <a class="reference internal" href="reference/datamodel.html#object.__delete__" title="object.__delete__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__delete__()</span></code></a>.
  420. When a class attribute is a descriptor, its special
  421. binding behavior is triggered upon attribute lookup. Normally, using
  422. <em>a.b</em> to get, set or delete an attribute looks up the object named <em>b</em> in
  423. the class dictionary for <em>a</em>, but if <em>b</em> is a descriptor, the respective
  424. descriptor method gets called. Understanding descriptors is a key to a
  425. deep understanding of Python because they are the basis for many features
  426. including functions, methods, properties, class methods, static methods,
  427. and reference to super classes.</p>
  428. <p>For more information about descriptors’ methods, see <a class="reference internal" href="reference/datamodel.html#descriptors"><span class="std std-ref">Implementing Descriptors</span></a>
  429. or the <a class="reference internal" href="howto/descriptor.html#descriptorhowto"><span class="std std-ref">Descriptor How To Guide</span></a>.</p>
  430. </dd>
  431. <dt id="term-dictionary">dictionary<a class="headerlink" href="#term-dictionary" title="Link to this term">¶</a></dt><dd><p>An associative array, where arbitrary keys are mapped to values. The
  432. keys can be any object with <a class="reference internal" href="reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> and
  433. <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> methods.
  434. Called a hash in Perl.</p>
  435. </dd>
  436. <dt id="term-dictionary-comprehension">dictionary comprehension<a class="headerlink" href="#term-dictionary-comprehension" title="Link to this term">¶</a></dt><dd><p>A compact way to process all or part of the elements in an iterable and
  437. return a dictionary with the results. <code class="docutils literal notranslate"><span class="pre">results</span> <span class="pre">=</span> <span class="pre">{n:</span> <span class="pre">n</span> <span class="pre">**</span> <span class="pre">2</span> <span class="pre">for</span> <span class="pre">n</span> <span class="pre">in</span>
  438. <span class="pre">range(10)}</span></code> generates a dictionary containing key <code class="docutils literal notranslate"><span class="pre">n</span></code> mapped to
  439. value <code class="docutils literal notranslate"><span class="pre">n</span> <span class="pre">**</span> <span class="pre">2</span></code>. See <a class="reference internal" href="reference/expressions.html#comprehensions"><span class="std std-ref">Displays for lists, sets and dictionaries</span></a>.</p>
  440. </dd>
  441. <dt id="term-dictionary-view">dictionary view<a class="headerlink" href="#term-dictionary-view" title="Link to this term">¶</a></dt><dd><p>The objects returned from <a class="reference internal" href="library/stdtypes.html#dict.keys" title="dict.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.keys()</span></code></a>, <a class="reference internal" href="library/stdtypes.html#dict.values" title="dict.values"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.values()</span></code></a>, and
  442. <a class="reference internal" href="library/stdtypes.html#dict.items" title="dict.items"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.items()</span></code></a> are called dictionary views. They provide a dynamic
  443. view on the dictionary’s entries, which means that when the dictionary
  444. changes, the view reflects these changes. To force the
  445. dictionary view to become a full list use <code class="docutils literal notranslate"><span class="pre">list(dictview)</span></code>. See
  446. <a class="reference internal" href="library/stdtypes.html#dict-views"><span class="std std-ref">Dictionary view objects</span></a>.</p>
  447. </dd>
  448. <dt id="term-docstring">docstring<a class="headerlink" href="#term-docstring" title="Link to this term">¶</a></dt><dd><p>A string literal which appears as the first expression in a class,
  449. function or module. While ignored when the suite is executed, it is
  450. recognized by the compiler and put into the <code class="xref py py-attr docutils literal notranslate"><span class="pre">__doc__</span></code> attribute
  451. of the enclosing class, function or module. Since it is available via
  452. introspection, it is the canonical place for documentation of the
  453. object.</p>
  454. </dd>
  455. <dt id="term-duck-typing">duck-typing<a class="headerlink" href="#term-duck-typing" title="Link to this term">¶</a></dt><dd><p>A programming style which does not look at an object’s type to determine
  456. if it has the right interface; instead, the method or attribute is simply
  457. called or used (“If it looks like a duck and quacks like a duck, it
  458. must be a duck.”) By emphasizing interfaces rather than specific types,
  459. well-designed code improves its flexibility by allowing polymorphic
  460. substitution. Duck-typing avoids tests using <a class="reference internal" href="library/functions.html#type" title="type"><code class="xref py py-func docutils literal notranslate"><span class="pre">type()</span></code></a> or
  461. <a class="reference internal" href="library/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a>. (Note, however, that duck-typing can be complemented
  462. with <a class="reference internal" href="#term-abstract-base-class"><span class="xref std std-term">abstract base classes</span></a>.) Instead, it
  463. typically employs <a class="reference internal" href="library/functions.html#hasattr" title="hasattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">hasattr()</span></code></a> tests or <a class="reference internal" href="#term-EAFP"><span class="xref std std-term">EAFP</span></a> programming.</p>
  464. </dd>
  465. <dt id="term-EAFP">EAFP<a class="headerlink" href="#term-EAFP" title="Link to this term">¶</a></dt><dd><p>Easier to ask for forgiveness than permission. This common Python coding
  466. style assumes the existence of valid keys or attributes and catches
  467. exceptions if the assumption proves false. This clean and fast style is
  468. characterized by the presence of many <a class="reference internal" href="reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> and <a class="reference internal" href="reference/compound_stmts.html#except"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">except</span></code></a>
  469. statements. The technique contrasts with the <a class="reference internal" href="#term-LBYL"><span class="xref std std-term">LBYL</span></a> style
  470. common to many other languages such as C.</p>
  471. </dd>
  472. <dt id="term-expression">expression<a class="headerlink" href="#term-expression" title="Link to this term">¶</a></dt><dd><p>A piece of syntax which can be evaluated to some value. In other words,
  473. an expression is an accumulation of expression elements like literals,
  474. names, attribute access, operators or function calls which all return a
  475. value. In contrast to many other languages, not all language constructs
  476. are expressions. There are also <a class="reference internal" href="#term-statement"><span class="xref std std-term">statement</span></a>s which cannot be used
  477. as expressions, such as <a class="reference internal" href="reference/compound_stmts.html#while"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">while</span></code></a>. Assignments are also statements,
  478. not expressions.</p>
  479. </dd>
  480. <dt id="term-extension-module">extension module<a class="headerlink" href="#term-extension-module" title="Link to this term">¶</a></dt><dd><p>A module written in C or C++, using Python’s C API to interact with the
  481. core and with user code.</p>
  482. </dd>
  483. <dt id="term-f-string">f-string<a class="headerlink" href="#term-f-string" title="Link to this term">¶</a></dt><dd><p>String literals prefixed with <code class="docutils literal notranslate"><span class="pre">'f'</span></code> or <code class="docutils literal notranslate"><span class="pre">'F'</span></code> are commonly called
  484. “f-strings” which is short for
  485. <a class="reference internal" href="reference/lexical_analysis.html#f-strings"><span class="std std-ref">formatted string literals</span></a>. See also <span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-0498/"><strong>PEP 498</strong></a>.</p>
  486. </dd>
  487. <dt id="term-file-object">file object<a class="headerlink" href="#term-file-object" title="Link to this term">¶</a></dt><dd><p>An object exposing a file-oriented API (with methods such as
  488. <code class="xref py py-meth docutils literal notranslate"><span class="pre">read()</span></code> or <code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code>) to an underlying resource. Depending
  489. on the way it was created, a file object can mediate access to a real
  490. on-disk file or to another type of storage or communication device
  491. (for example standard input/output, in-memory buffers, sockets, pipes,
  492. etc.). File objects are also called <em class="dfn">file-like objects</em> or
  493. <em class="dfn">streams</em>.</p>
  494. <p>There are actually three categories of file objects: raw
  495. <a class="reference internal" href="#term-binary-file"><span class="xref std std-term">binary files</span></a>, buffered
  496. <a class="reference internal" href="#term-binary-file"><span class="xref std std-term">binary files</span></a> and <a class="reference internal" href="#term-text-file"><span class="xref std std-term">text files</span></a>.
  497. Their interfaces are defined in the <a class="reference internal" href="library/io.html#module-io" title="io: Core tools for working with streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">io</span></code></a> module. The canonical
  498. way to create a file object is by using the <a class="reference internal" href="library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> function.</p>
  499. </dd>
  500. <dt id="term-file-like-object">file-like object<a class="headerlink" href="#term-file-like-object" title="Link to this term">¶</a></dt><dd><p>A synonym for <a class="reference internal" href="#term-file-object"><span class="xref std std-term">file object</span></a>.</p>
  501. </dd>
  502. <dt id="term-filesystem-encoding-and-error-handler">filesystem encoding and error handler<a class="headerlink" href="#term-filesystem-encoding-and-error-handler" title="Link to this term">¶</a></dt><dd><p>Encoding and error handler used by Python to decode bytes from the
  503. operating system and encode Unicode to the operating system.</p>
  504. <p>The filesystem encoding must guarantee to successfully decode all bytes
  505. below 128. If the file system encoding fails to provide this guarantee,
  506. API functions can raise <a class="reference internal" href="library/exceptions.html#UnicodeError" title="UnicodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeError</span></code></a>.</p>
  507. <p>The <a class="reference internal" href="library/sys.html#sys.getfilesystemencoding" title="sys.getfilesystemencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getfilesystemencoding()</span></code></a> and
  508. <a class="reference internal" href="library/sys.html#sys.getfilesystemencodeerrors" title="sys.getfilesystemencodeerrors"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getfilesystemencodeerrors()</span></code></a> functions can be used to get the
  509. filesystem encoding and error handler.</p>
  510. <p>The <a class="reference internal" href="#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a> are configured at
  511. Python startup by the <a class="reference internal" href="c-api/init_config.html#c.PyConfig_Read" title="PyConfig_Read"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Read()</span></code></a> function: see
  512. <a class="reference internal" href="c-api/init_config.html#c.PyConfig.filesystem_encoding" title="PyConfig.filesystem_encoding"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_encoding</span></code></a> and
  513. <a class="reference internal" href="c-api/init_config.html#c.PyConfig.filesystem_errors" title="PyConfig.filesystem_errors"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_errors</span></code></a> members of <a class="reference internal" href="c-api/init_config.html#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a>.</p>
  514. <p>See also the <a class="reference internal" href="#term-locale-encoding"><span class="xref std std-term">locale encoding</span></a>.</p>
  515. </dd>
  516. <dt id="term-finder">finder<a class="headerlink" href="#term-finder" title="Link to this term">¶</a></dt><dd><p>An object that tries to find the <a class="reference internal" href="#term-loader"><span class="xref std std-term">loader</span></a> for a module that is
  517. being imported.</p>
  518. <p>Since Python 3.3, there are two types of finder: <a class="reference internal" href="#term-meta-path-finder"><span class="xref std std-term">meta path finders</span></a> for use with <a class="reference internal" href="library/sys.html#sys.meta_path" title="sys.meta_path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a>, and <a class="reference internal" href="#term-path-entry-finder"><span class="xref std std-term">path
  519. entry finders</span></a> for use with <a class="reference internal" href="library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a>.</p>
  520. <p>See <span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-0302/"><strong>PEP 302</strong></a>, <span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-0420/"><strong>PEP 420</strong></a> and <span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0451/"><strong>PEP 451</strong></a> for much more detail.</p>
  521. </dd>
  522. <dt id="term-floor-division">floor division<a class="headerlink" href="#term-floor-division" title="Link to this term">¶</a></dt><dd><p>Mathematical division that rounds down to nearest integer. The floor
  523. division operator is <code class="docutils literal notranslate"><span class="pre">//</span></code>. For example, the expression <code class="docutils literal notranslate"><span class="pre">11</span> <span class="pre">//</span> <span class="pre">4</span></code>
  524. evaluates to <code class="docutils literal notranslate"><span class="pre">2</span></code> in contrast to the <code class="docutils literal notranslate"><span class="pre">2.75</span></code> returned by float true
  525. division. Note that <code class="docutils literal notranslate"><span class="pre">(-11)</span> <span class="pre">//</span> <span class="pre">4</span></code> is <code class="docutils literal notranslate"><span class="pre">-3</span></code> because that is <code class="docutils literal notranslate"><span class="pre">-2.75</span></code>
  526. rounded <em>downward</em>. See <span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0238/"><strong>PEP 238</strong></a>.</p>
  527. </dd>
  528. <dt id="term-function">function<a class="headerlink" href="#term-function" title="Link to this term">¶</a></dt><dd><p>A series of statements which returns some value to a caller. It can also
  529. be passed zero or more <a class="reference internal" href="#term-argument"><span class="xref std std-term">arguments</span></a> which may be used in
  530. the execution of the body. See also <a class="reference internal" href="#term-parameter"><span class="xref std std-term">parameter</span></a>, <a class="reference internal" href="#term-method"><span class="xref std std-term">method</span></a>,
  531. and the <a class="reference internal" href="reference/compound_stmts.html#function"><span class="std std-ref">Function definitions</span></a> section.</p>
  532. </dd>
  533. <dt id="term-function-annotation">function annotation<a class="headerlink" href="#term-function-annotation" title="Link to this term">¶</a></dt><dd><p>An <a class="reference internal" href="#term-annotation"><span class="xref std std-term">annotation</span></a> of a function parameter or return value.</p>
  534. <p>Function annotations are usually used for
  535. <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hints</span></a>: for example, this function is expected to take two
  536. <a class="reference internal" href="library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> arguments and is also expected to have an <a class="reference internal" href="library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>
  537. return value:</p>
  538. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sum_two_numbers</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
  539. <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span>
  540. </pre></div>
  541. </div>
  542. <p>Function annotation syntax is explained in section <a class="reference internal" href="reference/compound_stmts.html#function"><span class="std std-ref">Function definitions</span></a>.</p>
  543. <p>See <a class="reference internal" href="#term-variable-annotation"><span class="xref std std-term">variable annotation</span></a> and <span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>,
  544. which describe this functionality.
  545. Also see <a class="reference internal" href="howto/annotations.html#annotations-howto"><span class="std std-ref">Annotations Best Practices</span></a>
  546. for best practices on working with annotations.</p>
  547. </dd>
  548. <dt id="term-__future__">__future__<a class="headerlink" href="#term-__future__" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="reference/simple_stmts.html#future"><span class="std std-ref">future statement</span></a>, <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">&lt;feature&gt;</span></code>,
  549. directs the compiler to compile the current module using syntax or
  550. semantics that will become standard in a future release of Python.
  551. The <a class="reference internal" href="library/__future__.html#module-__future__" title="__future__: Future statement definitions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__future__</span></code></a> module documents the possible values of
  552. <em>feature</em>. By importing this module and evaluating its variables,
  553. you can see when a new feature was first added to the language and
  554. when it will (or did) become the default:</p>
  555. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">__future__</span>
  556. <span class="gp">&gt;&gt;&gt; </span><span class="n">__future__</span><span class="o">.</span><span class="n">division</span>
  557. <span class="go">_Feature((2, 2, 0, &#39;alpha&#39;, 2), (3, 0, 0, &#39;alpha&#39;, 0), 8192)</span>
  558. </pre></div>
  559. </div>
  560. </dd>
  561. <dt id="term-garbage-collection">garbage collection<a class="headerlink" href="#term-garbage-collection" title="Link to this term">¶</a></dt><dd><p>The process of freeing memory when it is not used anymore. Python
  562. performs garbage collection via reference counting and a cyclic garbage
  563. collector that is able to detect and break reference cycles. The
  564. garbage collector can be controlled using the <a class="reference internal" href="library/gc.html#module-gc" title="gc: Interface to the cycle-detecting garbage collector."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gc</span></code></a> module.</p>
  565. </dd>
  566. <dt id="term-generator">generator<a class="headerlink" href="#term-generator" title="Link to this term">¶</a></dt><dd><p>A function which returns a <a class="reference internal" href="#term-generator-iterator"><span class="xref std std-term">generator iterator</span></a>. It looks like a
  567. normal function except that it contains <a class="reference internal" href="reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> expressions
  568. for producing a series of values usable in a for-loop or that can be
  569. retrieved one at a time with the <a class="reference internal" href="library/functions.html#next" title="next"><code class="xref py py-func docutils literal notranslate"><span class="pre">next()</span></code></a> function.</p>
  570. <p>Usually refers to a generator function, but may refer to a
  571. <em>generator iterator</em> in some contexts. In cases where the intended
  572. meaning isn’t clear, using the full terms avoids ambiguity.</p>
  573. </dd>
  574. <dt id="term-generator-iterator">generator iterator<a class="headerlink" href="#term-generator-iterator" title="Link to this term">¶</a></dt><dd><p>An object created by a <a class="reference internal" href="#term-generator"><span class="xref std std-term">generator</span></a> function.</p>
  575. <p>Each <a class="reference internal" href="reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> temporarily suspends processing, remembering the
  576. location execution state (including local variables and pending
  577. try-statements). When the <em>generator iterator</em> resumes, it picks up where
  578. it left off (in contrast to functions which start fresh on every
  579. invocation).</p>
  580. </dd>
  581. <dt id="term-generator-expression">generator expression<a class="headerlink" href="#term-generator-expression" title="Link to this term">¶</a></dt><dd><p>An expression that returns an iterator. It looks like a normal expression
  582. followed by a <code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code> clause defining a loop variable, range,
  583. and an optional <code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code> clause. The combined expression
  584. generates values for an enclosing function:</p>
  585. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">sum</span><span class="p">(</span><span class="n">i</span><span class="o">*</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span> <span class="c1"># sum of squares 0, 1, 4, ... 81</span>
  586. <span class="go">285</span>
  587. </pre></div>
  588. </div>
  589. </dd>
  590. <dt id="term-generic-function">generic function<a class="headerlink" href="#term-generic-function" title="Link to this term">¶</a></dt><dd><p>A function composed of multiple functions implementing the same operation
  591. for different types. Which implementation should be used during a call is
  592. determined by the dispatch algorithm.</p>
  593. <p>See also the <a class="reference internal" href="#term-single-dispatch"><span class="xref std std-term">single dispatch</span></a> glossary entry, the
  594. <a class="reference internal" href="library/functools.html#functools.singledispatch" title="functools.singledispatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.singledispatch()</span></code></a> decorator, and <span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0443/"><strong>PEP 443</strong></a>.</p>
  595. </dd>
  596. <dt id="term-generic-type">generic type<a class="headerlink" href="#term-generic-type" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="#term-type"><span class="xref std std-term">type</span></a> that can be parameterized; typically a
  597. <a class="reference internal" href="reference/datamodel.html#sequence-types"><span class="std std-ref">container class</span></a> such as <a class="reference internal" href="library/stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> or
  598. <a class="reference internal" href="library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>. Used for <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hints</span></a> and
  599. <a class="reference internal" href="#term-annotation"><span class="xref std std-term">annotations</span></a>.</p>
  600. <p>For more details, see <a class="reference internal" href="library/stdtypes.html#types-genericalias"><span class="std std-ref">generic alias types</span></a>,
  601. <span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-0483/"><strong>PEP 483</strong></a>, <span class="target" id="index-23"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>, <span class="target" id="index-24"></span><a class="pep reference external" href="https://peps.python.org/pep-0585/"><strong>PEP 585</strong></a>, and the <a class="reference internal" href="library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module.</p>
  602. </dd>
  603. <dt id="term-GIL">GIL<a class="headerlink" href="#term-GIL" title="Link to this term">¶</a></dt><dd><p>See <a class="reference internal" href="#term-global-interpreter-lock"><span class="xref std std-term">global interpreter lock</span></a>.</p>
  604. </dd>
  605. <dt id="term-global-interpreter-lock">global interpreter lock<a class="headerlink" href="#term-global-interpreter-lock" title="Link to this term">¶</a></dt><dd><p>The mechanism used by the <a class="reference internal" href="#term-CPython"><span class="xref std std-term">CPython</span></a> interpreter to assure that
  606. only one thread executes Python <a class="reference internal" href="#term-bytecode"><span class="xref std std-term">bytecode</span></a> at a time.
  607. This simplifies the CPython implementation by making the object model
  608. (including critical built-in types such as <a class="reference internal" href="library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>) implicitly
  609. safe against concurrent access. Locking the entire interpreter
  610. makes it easier for the interpreter to be multi-threaded, at the
  611. expense of much of the parallelism afforded by multi-processor
  612. machines.</p>
  613. <p>However, some extension modules, either standard or third-party,
  614. are designed so as to release the GIL when doing computationally intensive
  615. tasks such as compression or hashing. Also, the GIL is always released
  616. when doing I/O.</p>
  617. <p>Past efforts to create a “free-threaded” interpreter (one which locks
  618. shared data at a much finer granularity) have not been successful
  619. because performance suffered in the common single-processor case. It
  620. is believed that overcoming this performance issue would make the
  621. implementation much more complicated and therefore costlier to maintain.</p>
  622. </dd>
  623. <dt id="term-hash-based-pyc">hash-based pyc<a class="headerlink" href="#term-hash-based-pyc" title="Link to this term">¶</a></dt><dd><p>A bytecode cache file that uses the hash rather than the last-modified
  624. time of the corresponding source file to determine its validity. See
  625. <a class="reference internal" href="reference/import.html#pyc-invalidation"><span class="std std-ref">Cached bytecode invalidation</span></a>.</p>
  626. </dd>
  627. <dt id="term-hashable">hashable<a class="headerlink" href="#term-hashable" title="Link to this term">¶</a></dt><dd><p>An object is <em>hashable</em> if it has a hash value which never changes during
  628. its lifetime (it needs a <a class="reference internal" href="reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> method), and can be
  629. compared to other objects (it needs an <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> method).
  630. Hashable objects which
  631. compare equal must have the same hash value.</p>
  632. <p>Hashability makes an object usable as a dictionary key and a set member,
  633. because these data structures use the hash value internally.</p>
  634. <p>Most of Python’s immutable built-in objects are hashable; mutable
  635. containers (such as lists or dictionaries) are not; immutable
  636. containers (such as tuples and frozensets) are only hashable if
  637. their elements are hashable. Objects which are
  638. instances of user-defined classes are hashable by default. They all
  639. compare unequal (except with themselves), and their hash value is derived
  640. from their <a class="reference internal" href="library/functions.html#id" title="id"><code class="xref py py-func docutils literal notranslate"><span class="pre">id()</span></code></a>.</p>
  641. </dd>
  642. <dt id="term-IDLE">IDLE<a class="headerlink" href="#term-IDLE" title="Link to this term">¶</a></dt><dd><p>An Integrated Development and Learning Environment for Python.
  643. <a class="reference internal" href="library/idle.html#idle"><span class="std std-ref">IDLE</span></a> is a basic editor and interpreter environment
  644. which ships with the standard distribution of Python.</p>
  645. </dd>
  646. <dt id="term-immutable">immutable<a class="headerlink" href="#term-immutable" title="Link to this term">¶</a></dt><dd><p>An object with a fixed value. Immutable objects include numbers, strings and
  647. tuples. Such an object cannot be altered. A new object has to
  648. be created if a different value has to be stored. They play an important
  649. role in places where a constant hash value is needed, for example as a key
  650. in a dictionary.</p>
  651. </dd>
  652. <dt id="term-import-path">import path<a class="headerlink" href="#term-import-path" title="Link to this term">¶</a></dt><dd><p>A list of locations (or <a class="reference internal" href="#term-path-entry"><span class="xref std std-term">path entries</span></a>) that are
  653. searched by the <a class="reference internal" href="#term-path-based-finder"><span class="xref std std-term">path based finder</span></a> for modules to import. During
  654. import, this list of locations usually comes from <a class="reference internal" href="library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>, but
  655. for subpackages it may also come from the parent package’s <code class="docutils literal notranslate"><span class="pre">__path__</span></code>
  656. attribute.</p>
  657. </dd>
  658. <dt id="term-importing">importing<a class="headerlink" href="#term-importing" title="Link to this term">¶</a></dt><dd><p>The process by which Python code in one module is made available to
  659. Python code in another module.</p>
  660. </dd>
  661. <dt id="term-importer">importer<a class="headerlink" href="#term-importer" title="Link to this term">¶</a></dt><dd><p>An object that both finds and loads a module; both a
  662. <a class="reference internal" href="#term-finder"><span class="xref std std-term">finder</span></a> and <a class="reference internal" href="#term-loader"><span class="xref std std-term">loader</span></a> object.</p>
  663. </dd>
  664. <dt id="term-interactive">interactive<a class="headerlink" href="#term-interactive" title="Link to this term">¶</a></dt><dd><p>Python has an interactive interpreter which means you can enter
  665. statements and expressions at the interpreter prompt, immediately
  666. execute them and see their results. Just launch <code class="docutils literal notranslate"><span class="pre">python</span></code> with no
  667. arguments (possibly by selecting it from your computer’s main
  668. menu). It is a very powerful way to test out new ideas or inspect
  669. modules and packages (remember <code class="docutils literal notranslate"><span class="pre">help(x)</span></code>).</p>
  670. </dd>
  671. <dt id="term-interpreted">interpreted<a class="headerlink" href="#term-interpreted" title="Link to this term">¶</a></dt><dd><p>Python is an interpreted language, as opposed to a compiled one,
  672. though the distinction can be blurry because of the presence of the
  673. bytecode compiler. This means that source files can be run directly
  674. without explicitly creating an executable which is then run.
  675. Interpreted languages typically have a shorter development/debug cycle
  676. than compiled ones, though their programs generally also run more
  677. slowly. See also <a class="reference internal" href="#term-interactive"><span class="xref std std-term">interactive</span></a>.</p>
  678. </dd>
  679. <dt id="term-interpreter-shutdown">interpreter shutdown<a class="headerlink" href="#term-interpreter-shutdown" title="Link to this term">¶</a></dt><dd><p>When asked to shut down, the Python interpreter enters a special phase
  680. where it gradually releases all allocated resources, such as modules
  681. and various critical internal structures. It also makes several calls
  682. to the <a class="reference internal" href="#term-garbage-collection"><span class="xref std std-term">garbage collector</span></a>. This can trigger
  683. the execution of code in user-defined destructors or weakref callbacks.
  684. Code executed during the shutdown phase can encounter various
  685. exceptions as the resources it relies on may not function anymore
  686. (common examples are library modules or the warnings machinery).</p>
  687. <p>The main reason for interpreter shutdown is that the <code class="docutils literal notranslate"><span class="pre">__main__</span></code> module
  688. or the script being run has finished executing.</p>
  689. </dd>
  690. <dt id="term-iterable">iterable<a class="headerlink" href="#term-iterable" title="Link to this term">¶</a></dt><dd><p>An object capable of returning its members one at a time. Examples of
  691. iterables include all sequence types (such as <a class="reference internal" href="library/stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>, <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>,
  692. and <a class="reference internal" href="library/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>) and some non-sequence types like <a class="reference internal" href="library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>,
  693. <a class="reference internal" href="#term-file-object"><span class="xref std std-term">file objects</span></a>, and objects of any classes you define
  694. with an <a class="reference internal" href="library/stdtypes.html#iterator.__iter__" title="iterator.__iter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__iter__()</span></code></a> method or with a
  695. <a class="reference internal" href="reference/datamodel.html#object.__getitem__" title="object.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a> method
  696. that implements <a class="reference internal" href="#term-sequence"><span class="xref std std-term">sequence</span></a> semantics.</p>
  697. <p>Iterables can be
  698. used in a <a class="reference internal" href="reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a> loop and in many other places where a sequence is
  699. needed (<a class="reference internal" href="library/functions.html#zip" title="zip"><code class="xref py py-func docutils literal notranslate"><span class="pre">zip()</span></code></a>, <a class="reference internal" href="library/functions.html#map" title="map"><code class="xref py py-func docutils literal notranslate"><span class="pre">map()</span></code></a>, …). When an iterable object is passed
  700. as an argument to the built-in function <a class="reference internal" href="library/functions.html#iter" title="iter"><code class="xref py py-func docutils literal notranslate"><span class="pre">iter()</span></code></a>, it returns an
  701. iterator for the object. This iterator is good for one pass over the set
  702. of values. When using iterables, it is usually not necessary to call
  703. <a class="reference internal" href="library/functions.html#iter" title="iter"><code class="xref py py-func docutils literal notranslate"><span class="pre">iter()</span></code></a> or deal with iterator objects yourself. The <a class="reference internal" href="reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a>
  704. statement does that automatically for you, creating a temporary unnamed
  705. variable to hold the iterator for the duration of the loop. See also
  706. <a class="reference internal" href="#term-iterator"><span class="xref std std-term">iterator</span></a>, <a class="reference internal" href="#term-sequence"><span class="xref std std-term">sequence</span></a>, and <a class="reference internal" href="#term-generator"><span class="xref std std-term">generator</span></a>.</p>
  707. </dd>
  708. <dt id="term-iterator">iterator<a class="headerlink" href="#term-iterator" title="Link to this term">¶</a></dt><dd><p>An object representing a stream of data. Repeated calls to the iterator’s
  709. <a class="reference internal" href="library/stdtypes.html#iterator.__next__" title="iterator.__next__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__next__()</span></code></a> method (or passing it to the built-in function
  710. <a class="reference internal" href="library/functions.html#next" title="next"><code class="xref py py-func docutils literal notranslate"><span class="pre">next()</span></code></a>) return successive items in the stream. When no more data
  711. are available a <a class="reference internal" href="library/exceptions.html#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exception is raised instead. At this
  712. point, the iterator object is exhausted and any further calls to its
  713. <code class="xref py py-meth docutils literal notranslate"><span class="pre">__next__()</span></code> method just raise <a class="reference internal" href="library/exceptions.html#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> again. Iterators
  714. are required to have an <a class="reference internal" href="library/stdtypes.html#iterator.__iter__" title="iterator.__iter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__iter__()</span></code></a> method that returns the iterator
  715. object itself so every iterator is also iterable and may be used in most
  716. places where other iterables are accepted. One notable exception is code
  717. which attempts multiple iteration passes. A container object (such as a
  718. <a class="reference internal" href="library/stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>) produces a fresh new iterator each time you pass it to the
  719. <a class="reference internal" href="library/functions.html#iter" title="iter"><code class="xref py py-func docutils literal notranslate"><span class="pre">iter()</span></code></a> function or use it in a <a class="reference internal" href="reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a> loop. Attempting this
  720. with an iterator will just return the same exhausted iterator object used
  721. in the previous iteration pass, making it appear like an empty container.</p>
  722. <p>More information can be found in <a class="reference internal" href="library/stdtypes.html#typeiter"><span class="std std-ref">Iterator Types</span></a>.</p>
  723. <div class="impl-detail compound">
  724. <p><strong>CPython implementation detail:</strong> CPython does not consistently apply the requirement that an iterator
  725. define <a class="reference internal" href="library/stdtypes.html#iterator.__iter__" title="iterator.__iter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__iter__()</span></code></a>.</p>
  726. </div>
  727. </dd>
  728. <dt id="term-key-function">key function<a class="headerlink" href="#term-key-function" title="Link to this term">¶</a></dt><dd><p>A key function or collation function is a callable that returns a value
  729. used for sorting or ordering. For example, <a class="reference internal" href="library/locale.html#locale.strxfrm" title="locale.strxfrm"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.strxfrm()</span></code></a> is
  730. used to produce a sort key that is aware of locale specific sort
  731. conventions.</p>
  732. <p>A number of tools in Python accept key functions to control how elements
  733. are ordered or grouped. They include <a class="reference internal" href="library/functions.html#min" title="min"><code class="xref py py-func docutils literal notranslate"><span class="pre">min()</span></code></a>, <a class="reference internal" href="library/functions.html#max" title="max"><code class="xref py py-func docutils literal notranslate"><span class="pre">max()</span></code></a>,
  734. <a class="reference internal" href="library/functions.html#sorted" title="sorted"><code class="xref py py-func docutils literal notranslate"><span class="pre">sorted()</span></code></a>, <a class="reference internal" href="library/stdtypes.html#list.sort" title="list.sort"><code class="xref py py-meth docutils literal notranslate"><span class="pre">list.sort()</span></code></a>, <a class="reference internal" href="library/heapq.html#heapq.merge" title="heapq.merge"><code class="xref py py-func docutils literal notranslate"><span class="pre">heapq.merge()</span></code></a>,
  735. <a class="reference internal" href="library/heapq.html#heapq.nsmallest" title="heapq.nsmallest"><code class="xref py py-func docutils literal notranslate"><span class="pre">heapq.nsmallest()</span></code></a>, <a class="reference internal" href="library/heapq.html#heapq.nlargest" title="heapq.nlargest"><code class="xref py py-func docutils literal notranslate"><span class="pre">heapq.nlargest()</span></code></a>, and
  736. <a class="reference internal" href="library/itertools.html#itertools.groupby" title="itertools.groupby"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.groupby()</span></code></a>.</p>
  737. <p>There are several ways to create a key function. For example. the
  738. <a class="reference internal" href="library/stdtypes.html#str.lower" title="str.lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.lower()</span></code></a> method can serve as a key function for case insensitive
  739. sorts. Alternatively, a key function can be built from a
  740. <a class="reference internal" href="reference/expressions.html#lambda"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">lambda</span></code></a> expression such as <code class="docutils literal notranslate"><span class="pre">lambda</span> <span class="pre">r:</span> <span class="pre">(r[0],</span> <span class="pre">r[2])</span></code>. Also,
  741. <a class="reference internal" href="library/operator.html#operator.attrgetter" title="operator.attrgetter"><code class="xref py py-func docutils literal notranslate"><span class="pre">operator.attrgetter()</span></code></a>, <a class="reference internal" href="library/operator.html#operator.itemgetter" title="operator.itemgetter"><code class="xref py py-func docutils literal notranslate"><span class="pre">operator.itemgetter()</span></code></a>, and
  742. <a class="reference internal" href="library/operator.html#operator.methodcaller" title="operator.methodcaller"><code class="xref py py-func docutils literal notranslate"><span class="pre">operator.methodcaller()</span></code></a> are three key function constructors. See the <a class="reference internal" href="howto/sorting.html#sortinghowto"><span class="std std-ref">Sorting HOW TO</span></a> for examples of how to create and use key functions.</p>
  743. </dd>
  744. <dt id="term-keyword-argument">keyword argument<a class="headerlink" href="#term-keyword-argument" title="Link to this term">¶</a></dt><dd><p>See <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a>.</p>
  745. </dd>
  746. <dt id="term-lambda">lambda<a class="headerlink" href="#term-lambda" title="Link to this term">¶</a></dt><dd><p>An anonymous inline function consisting of a single <a class="reference internal" href="#term-expression"><span class="xref std std-term">expression</span></a>
  747. which is evaluated when the function is called. The syntax to create
  748. a lambda function is <code class="docutils literal notranslate"><span class="pre">lambda</span> <span class="pre">[parameters]:</span> <span class="pre">expression</span></code></p>
  749. </dd>
  750. <dt id="term-LBYL">LBYL<a class="headerlink" href="#term-LBYL" title="Link to this term">¶</a></dt><dd><p>Look before you leap. This coding style explicitly tests for
  751. pre-conditions before making calls or lookups. This style contrasts with
  752. the <a class="reference internal" href="#term-EAFP"><span class="xref std std-term">EAFP</span></a> approach and is characterized by the presence of many
  753. <a class="reference internal" href="reference/compound_stmts.html#if"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code></a> statements.</p>
  754. <p>In a multi-threaded environment, the LBYL approach can risk introducing a
  755. race condition between “the looking” and “the leaping”. For example, the
  756. code, <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">key</span> <span class="pre">in</span> <span class="pre">mapping:</span> <span class="pre">return</span> <span class="pre">mapping[key]</span></code> can fail if another
  757. thread removes <em>key</em> from <em>mapping</em> after the test, but before the lookup.
  758. This issue can be solved with locks or by using the EAFP approach.</p>
  759. </dd>
  760. <dt id="term-list">list<a class="headerlink" href="#term-list" title="Link to this term">¶</a></dt><dd><p>A built-in Python <a class="reference internal" href="#term-sequence"><span class="xref std std-term">sequence</span></a>. Despite its name it is more akin
  761. to an array in other languages than to a linked list since access to
  762. elements is <em>O</em>(1).</p>
  763. </dd>
  764. <dt id="term-list-comprehension">list comprehension<a class="headerlink" href="#term-list-comprehension" title="Link to this term">¶</a></dt><dd><p>A compact way to process all or part of the elements in a sequence and
  765. return a list with the results. <code class="docutils literal notranslate"><span class="pre">result</span> <span class="pre">=</span> <span class="pre">['{:#04x}'.format(x)</span> <span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span>
  766. <span class="pre">range(256)</span> <span class="pre">if</span> <span class="pre">x</span> <span class="pre">%</span> <span class="pre">2</span> <span class="pre">==</span> <span class="pre">0]</span></code> generates a list of strings containing
  767. even hex numbers (0x..) in the range from 0 to 255. The <a class="reference internal" href="reference/compound_stmts.html#if"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code></a>
  768. clause is optional. If omitted, all elements in <code class="docutils literal notranslate"><span class="pre">range(256)</span></code> are
  769. processed.</p>
  770. </dd>
  771. <dt id="term-loader">loader<a class="headerlink" href="#term-loader" title="Link to this term">¶</a></dt><dd><p>An object that loads a module. It must define a method named
  772. <code class="xref py py-meth docutils literal notranslate"><span class="pre">load_module()</span></code>. A loader is typically returned by a
  773. <a class="reference internal" href="#term-finder"><span class="xref std std-term">finder</span></a>. See <span class="target" id="index-25"></span><a class="pep reference external" href="https://peps.python.org/pep-0302/"><strong>PEP 302</strong></a> for details and
  774. <a class="reference internal" href="library/importlib.html#importlib.abc.Loader" title="importlib.abc.Loader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.Loader</span></code></a> for an <a class="reference internal" href="#term-abstract-base-class"><span class="xref std std-term">abstract base class</span></a>.</p>
  775. </dd>
  776. <dt id="term-locale-encoding">locale encoding<a class="headerlink" href="#term-locale-encoding" title="Link to this term">¶</a></dt><dd><p>On Unix, it is the encoding of the LC_CTYPE locale. It can be set with
  777. <a class="reference internal" href="library/locale.html#locale.setlocale" title="locale.setlocale"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.setlocale(locale.LC_CTYPE,</span> <span class="pre">new_locale)</span></code></a>.</p>
  778. <p>On Windows, it is the ANSI code page (ex: <code class="docutils literal notranslate"><span class="pre">&quot;cp1252&quot;</span></code>).</p>
  779. <p>On Android and VxWorks, Python uses <code class="docutils literal notranslate"><span class="pre">&quot;utf-8&quot;</span></code> as the locale encoding.</p>
  780. <p><a class="reference internal" href="library/locale.html#locale.getencoding" title="locale.getencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getencoding()</span></code></a> can be used to get the locale encoding.</p>
  781. <p>See also the <a class="reference internal" href="#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>.</p>
  782. </dd>
  783. <dt id="term-magic-method">magic method<a class="headerlink" href="#term-magic-method" title="Link to this term">¶</a></dt><dd><p id="index-26">An informal synonym for <a class="reference internal" href="#term-special-method"><span class="xref std std-term">special method</span></a>.</p>
  784. </dd>
  785. <dt id="term-mapping">mapping<a class="headerlink" href="#term-mapping" title="Link to this term">¶</a></dt><dd><p>A container object that supports arbitrary key lookups and implements the
  786. methods specified in the <a class="reference internal" href="library/collections.abc.html#collections.abc.Mapping" title="collections.abc.Mapping"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.Mapping</span></code></a> or
  787. <a class="reference internal" href="library/collections.abc.html#collections.abc.MutableMapping" title="collections.abc.MutableMapping"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.MutableMapping</span></code></a>
  788. <a class="reference internal" href="library/collections.abc.html#collections-abstract-base-classes"><span class="std std-ref">abstract base classes</span></a>. Examples
  789. include <a class="reference internal" href="library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>, <a class="reference internal" href="library/collections.html#collections.defaultdict" title="collections.defaultdict"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.defaultdict</span></code></a>,
  790. <a class="reference internal" href="library/collections.html#collections.OrderedDict" title="collections.OrderedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.OrderedDict</span></code></a> and <a class="reference internal" href="library/collections.html#collections.Counter" title="collections.Counter"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.Counter</span></code></a>.</p>
  791. </dd>
  792. <dt id="term-meta-path-finder">meta path finder<a class="headerlink" href="#term-meta-path-finder" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="#term-finder"><span class="xref std std-term">finder</span></a> returned by a search of <a class="reference internal" href="library/sys.html#sys.meta_path" title="sys.meta_path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a>. Meta path
  793. finders are related to, but different from <a class="reference internal" href="#term-path-entry-finder"><span class="xref std std-term">path entry finders</span></a>.</p>
  794. <p>See <a class="reference internal" href="library/importlib.html#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.MetaPathFinder</span></code></a> for the methods that meta path
  795. finders implement.</p>
  796. </dd>
  797. <dt id="term-metaclass">metaclass<a class="headerlink" href="#term-metaclass" title="Link to this term">¶</a></dt><dd><p>The class of a class. Class definitions create a class name, a class
  798. dictionary, and a list of base classes. The metaclass is responsible for
  799. taking those three arguments and creating the class. Most object oriented
  800. programming languages provide a default implementation. What makes Python
  801. special is that it is possible to create custom metaclasses. Most users
  802. never need this tool, but when the need arises, metaclasses can provide
  803. powerful, elegant solutions. They have been used for logging attribute
  804. access, adding thread-safety, tracking object creation, implementing
  805. singletons, and many other tasks.</p>
  806. <p>More information can be found in <a class="reference internal" href="reference/datamodel.html#metaclasses"><span class="std std-ref">Metaclasses</span></a>.</p>
  807. </dd>
  808. <dt id="term-method">method<a class="headerlink" href="#term-method" title="Link to this term">¶</a></dt><dd><p>A function which is defined inside a class body. If called as an attribute
  809. of an instance of that class, the method will get the instance object as
  810. its first <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a> (which is usually called <code class="docutils literal notranslate"><span class="pre">self</span></code>).
  811. See <a class="reference internal" href="#term-function"><span class="xref std std-term">function</span></a> and <a class="reference internal" href="#term-nested-scope"><span class="xref std std-term">nested scope</span></a>.</p>
  812. </dd>
  813. <dt id="term-method-resolution-order">method resolution order<a class="headerlink" href="#term-method-resolution-order" title="Link to this term">¶</a></dt><dd><p>Method Resolution Order is the order in which base classes are searched
  814. for a member during lookup. See <a class="reference external" href="https://www.python.org/download/releases/2.3/mro/">The Python 2.3 Method Resolution Order</a> for details of the
  815. algorithm used by the Python interpreter since the 2.3 release.</p>
  816. </dd>
  817. <dt id="term-module">module<a class="headerlink" href="#term-module" title="Link to this term">¶</a></dt><dd><p>An object that serves as an organizational unit of Python code. Modules
  818. have a namespace containing arbitrary Python objects. Modules are loaded
  819. into Python by the process of <a class="reference internal" href="#term-importing"><span class="xref std std-term">importing</span></a>.</p>
  820. <p>See also <a class="reference internal" href="#term-package"><span class="xref std std-term">package</span></a>.</p>
  821. </dd>
  822. <dt id="term-module-spec">module spec<a class="headerlink" href="#term-module-spec" title="Link to this term">¶</a></dt><dd><p>A namespace containing the import-related information used to load a
  823. module. An instance of <a class="reference internal" href="library/importlib.html#importlib.machinery.ModuleSpec" title="importlib.machinery.ModuleSpec"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.ModuleSpec</span></code></a>.</p>
  824. </dd>
  825. <dt id="term-MRO">MRO<a class="headerlink" href="#term-MRO" title="Link to this term">¶</a></dt><dd><p>See <a class="reference internal" href="#term-method-resolution-order"><span class="xref std std-term">method resolution order</span></a>.</p>
  826. </dd>
  827. <dt id="term-mutable">mutable<a class="headerlink" href="#term-mutable" title="Link to this term">¶</a></dt><dd><p>Mutable objects can change their value but keep their <a class="reference internal" href="library/functions.html#id" title="id"><code class="xref py py-func docutils literal notranslate"><span class="pre">id()</span></code></a>. See
  828. also <a class="reference internal" href="#term-immutable"><span class="xref std std-term">immutable</span></a>.</p>
  829. </dd>
  830. <dt id="term-named-tuple">named tuple<a class="headerlink" href="#term-named-tuple" title="Link to this term">¶</a></dt><dd><p>The term “named tuple” applies to any type or class that inherits from
  831. tuple and whose indexable elements are also accessible using named
  832. attributes. The type or class may have other features as well.</p>
  833. <p>Several built-in types are named tuples, including the values returned
  834. by <a class="reference internal" href="library/time.html#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.localtime()</span></code></a> and <a class="reference internal" href="library/os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a>. Another example is
  835. <a class="reference internal" href="library/sys.html#sys.float_info" title="sys.float_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.float_info</span></code></a>:</p>
  836. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sys</span><span class="o">.</span><span class="n">float_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="c1"># indexed access</span>
  837. <span class="go">1024</span>
  838. <span class="gp">&gt;&gt;&gt; </span><span class="n">sys</span><span class="o">.</span><span class="n">float_info</span><span class="o">.</span><span class="n">max_exp</span> <span class="c1"># named field access</span>
  839. <span class="go">1024</span>
  840. <span class="gp">&gt;&gt;&gt; </span><span class="nb">isinstance</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">float_info</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)</span> <span class="c1"># kind of tuple</span>
  841. <span class="go">True</span>
  842. </pre></div>
  843. </div>
  844. <p>Some named tuples are built-in types (such as the above examples).
  845. Alternatively, a named tuple can be created from a regular class
  846. definition that inherits from <a class="reference internal" href="library/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> and that defines named
  847. fields. Such a class can be written by hand, or it can be created by
  848. inheriting <a class="reference internal" href="library/typing.html#typing.NamedTuple" title="typing.NamedTuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.NamedTuple</span></code></a>, or with the factory function
  849. <a class="reference internal" href="library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code></a>. The latter techniques also add some
  850. extra methods that may not be found in hand-written or built-in named
  851. tuples.</p>
  852. </dd>
  853. <dt id="term-namespace">namespace<a class="headerlink" href="#term-namespace" title="Link to this term">¶</a></dt><dd><p>The place where a variable is stored. Namespaces are implemented as
  854. dictionaries. There are the local, global and built-in namespaces as well
  855. as nested namespaces in objects (in methods). Namespaces support
  856. modularity by preventing naming conflicts. For instance, the functions
  857. <a class="reference internal" href="library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">builtins.open</span></code></a> and <a class="reference internal" href="library/os.html#os.open" title="os.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.open()</span></code></a> are distinguished by
  858. their namespaces. Namespaces also aid readability and maintainability by
  859. making it clear which module implements a function. For instance, writing
  860. <a class="reference internal" href="library/random.html#random.seed" title="random.seed"><code class="xref py py-func docutils literal notranslate"><span class="pre">random.seed()</span></code></a> or <a class="reference internal" href="library/itertools.html#itertools.islice" title="itertools.islice"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.islice()</span></code></a> makes it clear that those
  861. functions are implemented by the <a class="reference internal" href="library/random.html#module-random" title="random: Generate pseudo-random numbers with various common distributions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code></a> and <a class="reference internal" href="library/itertools.html#module-itertools" title="itertools: Functions creating iterators for efficient looping."><code class="xref py py-mod docutils literal notranslate"><span class="pre">itertools</span></code></a>
  862. modules, respectively.</p>
  863. </dd>
  864. <dt id="term-namespace-package">namespace package<a class="headerlink" href="#term-namespace-package" title="Link to this term">¶</a></dt><dd><p>A <span class="target" id="index-27"></span><a class="pep reference external" href="https://peps.python.org/pep-0420/"><strong>PEP 420</strong></a> <a class="reference internal" href="#term-package"><span class="xref std std-term">package</span></a> which serves only as a container for
  865. subpackages. Namespace packages may have no physical representation,
  866. and specifically are not like a <a class="reference internal" href="#term-regular-package"><span class="xref std std-term">regular package</span></a> because they
  867. have no <code class="docutils literal notranslate"><span class="pre">__init__.py</span></code> file.</p>
  868. <p>See also <a class="reference internal" href="#term-module"><span class="xref std std-term">module</span></a>.</p>
  869. </dd>
  870. <dt id="term-nested-scope">nested scope<a class="headerlink" href="#term-nested-scope" title="Link to this term">¶</a></dt><dd><p>The ability to refer to a variable in an enclosing definition. For
  871. instance, a function defined inside another function can refer to
  872. variables in the outer function. Note that nested scopes by default work
  873. only for reference and not for assignment. Local variables both read and
  874. write in the innermost scope. Likewise, global variables read and write
  875. to the global namespace. The <a class="reference internal" href="reference/simple_stmts.html#nonlocal"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">nonlocal</span></code></a> allows writing to outer
  876. scopes.</p>
  877. </dd>
  878. <dt id="term-new-style-class">new-style class<a class="headerlink" href="#term-new-style-class" title="Link to this term">¶</a></dt><dd><p>Old name for the flavor of classes now used for all class objects. In
  879. earlier Python versions, only new-style classes could use Python’s newer,
  880. versatile features like <a class="reference internal" href="reference/datamodel.html#object.__slots__" title="object.__slots__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__slots__</span></code></a>, descriptors,
  881. properties, <a class="reference internal" href="reference/datamodel.html#object.__getattribute__" title="object.__getattribute__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getattribute__()</span></code></a>, class methods, and static
  882. methods.</p>
  883. </dd>
  884. <dt id="term-object">object<a class="headerlink" href="#term-object" title="Link to this term">¶</a></dt><dd><p>Any data with state (attributes or value) and defined behavior
  885. (methods). Also the ultimate base class of any <a class="reference internal" href="#term-new-style-class"><span class="xref std std-term">new-style
  886. class</span></a>.</p>
  887. </dd>
  888. <dt id="term-package">package<a class="headerlink" href="#term-package" title="Link to this term">¶</a></dt><dd><p>A Python <a class="reference internal" href="#term-module"><span class="xref std std-term">module</span></a> which can contain submodules or recursively,
  889. subpackages. Technically, a package is a Python module with a
  890. <code class="docutils literal notranslate"><span class="pre">__path__</span></code> attribute.</p>
  891. <p>See also <a class="reference internal" href="#term-regular-package"><span class="xref std std-term">regular package</span></a> and <a class="reference internal" href="#term-namespace-package"><span class="xref std std-term">namespace package</span></a>.</p>
  892. </dd>
  893. <dt id="term-parameter">parameter<a class="headerlink" href="#term-parameter" title="Link to this term">¶</a></dt><dd><p>A named entity in a <a class="reference internal" href="#term-function"><span class="xref std std-term">function</span></a> (or method) definition that
  894. specifies an <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a> (or in some cases, arguments) that the
  895. function can accept. There are five kinds of parameter:</p>
  896. <ul>
  897. <li><p><em class="dfn">positional-or-keyword</em>: specifies an argument that can be passed
  898. either <a class="reference internal" href="#term-argument"><span class="xref std std-term">positionally</span></a> or as a <a class="reference internal" href="#term-argument"><span class="xref std std-term">keyword argument</span></a>. This is the default kind of parameter, for example <em>foo</em>
  899. and <em>bar</em> in the following:</p>
  900. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">foo</span><span class="p">,</span> <span class="n">bar</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="o">...</span>
  901. </pre></div>
  902. </div>
  903. </li>
  904. </ul>
  905. <ul id="positional-only-parameter">
  906. <li><p><em class="dfn">positional-only</em>: specifies an argument that can be supplied only
  907. by position. Positional-only parameters can be defined by including a
  908. <code class="docutils literal notranslate"><span class="pre">/</span></code> character in the parameter list of the function definition after
  909. them, for example <em>posonly1</em> and <em>posonly2</em> in the following:</p>
  910. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">posonly1</span><span class="p">,</span> <span class="n">posonly2</span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="n">positional_or_keyword</span><span class="p">):</span> <span class="o">...</span>
  911. </pre></div>
  912. </div>
  913. </li>
  914. </ul>
  915. <ul id="keyword-only-parameter">
  916. <li><p><em class="dfn">keyword-only</em>: specifies an argument that can be supplied only
  917. by keyword. Keyword-only parameters can be defined by including a
  918. single var-positional parameter or bare <code class="docutils literal notranslate"><span class="pre">*</span></code> in the parameter list
  919. of the function definition before them, for example <em>kw_only1</em> and
  920. <em>kw_only2</em> in the following:</p>
  921. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">kw_only1</span><span class="p">,</span> <span class="n">kw_only2</span><span class="p">):</span> <span class="o">...</span>
  922. </pre></div>
  923. </div>
  924. </li>
  925. <li><p><em class="dfn">var-positional</em>: specifies that an arbitrary sequence of
  926. positional arguments can be provided (in addition to any positional
  927. arguments already accepted by other parameters). Such a parameter can
  928. be defined by prepending the parameter name with <code class="docutils literal notranslate"><span class="pre">*</span></code>, for example
  929. <em>args</em> in the following:</p>
  930. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="o">...</span>
  931. </pre></div>
  932. </div>
  933. </li>
  934. <li><p><em class="dfn">var-keyword</em>: specifies that arbitrarily many keyword arguments
  935. can be provided (in addition to any keyword arguments already accepted
  936. by other parameters). Such a parameter can be defined by prepending
  937. the parameter name with <code class="docutils literal notranslate"><span class="pre">**</span></code>, for example <em>kwargs</em> in the example
  938. above.</p></li>
  939. </ul>
  940. <p>Parameters can specify both optional and required arguments, as well as
  941. default values for some optional arguments.</p>
  942. <p>See also the <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a> glossary entry, the FAQ question on
  943. <a class="reference internal" href="faq/programming.html#faq-argument-vs-parameter"><span class="std std-ref">the difference between arguments and parameters</span></a>, the <a class="reference internal" href="library/inspect.html#inspect.Parameter" title="inspect.Parameter"><code class="xref py py-class docutils literal notranslate"><span class="pre">inspect.Parameter</span></code></a> class, the
  944. <a class="reference internal" href="reference/compound_stmts.html#function"><span class="std std-ref">Function definitions</span></a> section, and <span class="target" id="index-28"></span><a class="pep reference external" href="https://peps.python.org/pep-0362/"><strong>PEP 362</strong></a>.</p>
  945. </dd>
  946. <dt id="term-path-entry">path entry<a class="headerlink" href="#term-path-entry" title="Link to this term">¶</a></dt><dd><p>A single location on the <a class="reference internal" href="#term-import-path"><span class="xref std std-term">import path</span></a> which the <a class="reference internal" href="#term-path-based-finder"><span class="xref std std-term">path
  947. based finder</span></a> consults to find modules for importing.</p>
  948. </dd>
  949. <dt id="term-path-entry-finder">path entry finder<a class="headerlink" href="#term-path-entry-finder" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="#term-finder"><span class="xref std std-term">finder</span></a> returned by a callable on <a class="reference internal" href="library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a>
  950. (i.e. a <a class="reference internal" href="#term-path-entry-hook"><span class="xref std std-term">path entry hook</span></a>) which knows how to locate modules given
  951. a <a class="reference internal" href="#term-path-entry"><span class="xref std std-term">path entry</span></a>.</p>
  952. <p>See <a class="reference internal" href="library/importlib.html#importlib.abc.PathEntryFinder" title="importlib.abc.PathEntryFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.PathEntryFinder</span></code></a> for the methods that path entry
  953. finders implement.</p>
  954. </dd>
  955. <dt id="term-path-entry-hook">path entry hook<a class="headerlink" href="#term-path-entry-hook" title="Link to this term">¶</a></dt><dd><p>A callable on the <a class="reference internal" href="library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a> list which returns a <a class="reference internal" href="#term-path-entry-finder"><span class="xref std std-term">path
  956. entry finder</span></a> if it knows how to find modules on a specific <a class="reference internal" href="#term-path-entry"><span class="xref std std-term">path
  957. entry</span></a>.</p>
  958. </dd>
  959. <dt id="term-path-based-finder">path based finder<a class="headerlink" href="#term-path-based-finder" title="Link to this term">¶</a></dt><dd><p>One of the default <a class="reference internal" href="#term-meta-path-finder"><span class="xref std std-term">meta path finders</span></a> which
  960. searches an <a class="reference internal" href="#term-import-path"><span class="xref std std-term">import path</span></a> for modules.</p>
  961. </dd>
  962. <dt id="term-path-like-object">path-like object<a class="headerlink" href="#term-path-like-object" title="Link to this term">¶</a></dt><dd><p>An object representing a file system path. A path-like object is either
  963. a <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object representing a path, or an object
  964. implementing the <a class="reference internal" href="library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> protocol. An object that supports
  965. the <a class="reference internal" href="library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> protocol can be converted to a <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or
  966. <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> file system path by calling the <a class="reference internal" href="library/os.html#os.fspath" title="os.fspath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fspath()</span></code></a> function;
  967. <a class="reference internal" href="library/os.html#os.fsdecode" title="os.fsdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsdecode()</span></code></a> and <a class="reference internal" href="library/os.html#os.fsencode" title="os.fsencode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsencode()</span></code></a> can be used to guarantee a
  968. <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> result instead, respectively. Introduced
  969. by <span class="target" id="index-29"></span><a class="pep reference external" href="https://peps.python.org/pep-0519/"><strong>PEP 519</strong></a>.</p>
  970. </dd>
  971. <dt id="term-PEP">PEP<a class="headerlink" href="#term-PEP" title="Link to this term">¶</a></dt><dd><p>Python Enhancement Proposal. A PEP is a design document
  972. providing information to the Python community, or describing a new
  973. feature for Python or its processes or environment. PEPs should
  974. provide a concise technical specification and a rationale for proposed
  975. features.</p>
  976. <p>PEPs are intended to be the primary mechanisms for proposing major new
  977. features, for collecting community input on an issue, and for documenting
  978. the design decisions that have gone into Python. The PEP author is
  979. responsible for building consensus within the community and documenting
  980. dissenting opinions.</p>
  981. <p>See <span class="target" id="index-30"></span><a class="pep reference external" href="https://peps.python.org/pep-0001/"><strong>PEP 1</strong></a>.</p>
  982. </dd>
  983. <dt id="term-portion">portion<a class="headerlink" href="#term-portion" title="Link to this term">¶</a></dt><dd><p>A set of files in a single directory (possibly stored in a zip file)
  984. that contribute to a namespace package, as defined in <span class="target" id="index-31"></span><a class="pep reference external" href="https://peps.python.org/pep-0420/"><strong>PEP 420</strong></a>.</p>
  985. </dd>
  986. <dt id="term-positional-argument">positional argument<a class="headerlink" href="#term-positional-argument" title="Link to this term">¶</a></dt><dd><p>See <a class="reference internal" href="#term-argument"><span class="xref std std-term">argument</span></a>.</p>
  987. </dd>
  988. <dt id="term-provisional-API">provisional API<a class="headerlink" href="#term-provisional-API" title="Link to this term">¶</a></dt><dd><p>A provisional API is one which has been deliberately excluded from
  989. the standard library’s backwards compatibility guarantees. While major
  990. changes to such interfaces are not expected, as long as they are marked
  991. provisional, backwards incompatible changes (up to and including removal
  992. of the interface) may occur if deemed necessary by core developers. Such
  993. changes will not be made gratuitously – they will occur only if serious
  994. fundamental flaws are uncovered that were missed prior to the inclusion
  995. of the API.</p>
  996. <p>Even for provisional APIs, backwards incompatible changes are seen as
  997. a “solution of last resort” - every attempt will still be made to find
  998. a backwards compatible resolution to any identified problems.</p>
  999. <p>This process allows the standard library to continue to evolve over
  1000. time, without locking in problematic design errors for extended periods
  1001. of time. See <span class="target" id="index-32"></span><a class="pep reference external" href="https://peps.python.org/pep-0411/"><strong>PEP 411</strong></a> for more details.</p>
  1002. </dd>
  1003. <dt id="term-provisional-package">provisional package<a class="headerlink" href="#term-provisional-package" title="Link to this term">¶</a></dt><dd><p>See <a class="reference internal" href="#term-provisional-API"><span class="xref std std-term">provisional API</span></a>.</p>
  1004. </dd>
  1005. <dt id="term-Python-3000">Python 3000<a class="headerlink" href="#term-Python-3000" title="Link to this term">¶</a></dt><dd><p>Nickname for the Python 3.x release line (coined long ago when the
  1006. release of version 3 was something in the distant future.) This is also
  1007. abbreviated “Py3k”.</p>
  1008. </dd>
  1009. <dt id="term-Pythonic">Pythonic<a class="headerlink" href="#term-Pythonic" title="Link to this term">¶</a></dt><dd><p>An idea or piece of code which closely follows the most common idioms
  1010. of the Python language, rather than implementing code using concepts
  1011. common to other languages. For example, a common idiom in Python is
  1012. to loop over all elements of an iterable using a <a class="reference internal" href="reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a>
  1013. statement. Many other languages don’t have this type of construct, so
  1014. people unfamiliar with Python sometimes use a numerical counter instead:</p>
  1015. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">food</span><span class="p">)):</span>
  1016. <span class="nb">print</span><span class="p">(</span><span class="n">food</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
  1017. </pre></div>
  1018. </div>
  1019. <p>As opposed to the cleaner, Pythonic method:</p>
  1020. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">piece</span> <span class="ow">in</span> <span class="n">food</span><span class="p">:</span>
  1021. <span class="nb">print</span><span class="p">(</span><span class="n">piece</span><span class="p">)</span>
  1022. </pre></div>
  1023. </div>
  1024. </dd>
  1025. <dt id="term-qualified-name">qualified name<a class="headerlink" href="#term-qualified-name" title="Link to this term">¶</a></dt><dd><p>A dotted name showing the “path” from a module’s global scope to a
  1026. class, function or method defined in that module, as defined in
  1027. <span class="target" id="index-33"></span><a class="pep reference external" href="https://peps.python.org/pep-3155/"><strong>PEP 3155</strong></a>. For top-level functions and classes, the qualified name
  1028. is the same as the object’s name:</p>
  1029. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
  1030. <span class="gp">... </span> <span class="k">class</span> <span class="nc">D</span><span class="p">:</span>
  1031. <span class="gp">... </span> <span class="k">def</span> <span class="nf">meth</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  1032. <span class="gp">... </span> <span class="k">pass</span>
  1033. <span class="gp">...</span>
  1034. <span class="gp">&gt;&gt;&gt; </span><span class="n">C</span><span class="o">.</span><span class="vm">__qualname__</span>
  1035. <span class="go">&#39;C&#39;</span>
  1036. <span class="gp">&gt;&gt;&gt; </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="vm">__qualname__</span>
  1037. <span class="go">&#39;C.D&#39;</span>
  1038. <span class="gp">&gt;&gt;&gt; </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="n">meth</span><span class="o">.</span><span class="vm">__qualname__</span>
  1039. <span class="go">&#39;C.D.meth&#39;</span>
  1040. </pre></div>
  1041. </div>
  1042. <p>When used to refer to modules, the <em>fully qualified name</em> means the
  1043. entire dotted path to the module, including any parent packages,
  1044. e.g. <code class="docutils literal notranslate"><span class="pre">email.mime.text</span></code>:</p>
  1045. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">email.mime.text</span>
  1046. <span class="gp">&gt;&gt;&gt; </span><span class="n">email</span><span class="o">.</span><span class="n">mime</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="vm">__name__</span>
  1047. <span class="go">&#39;email.mime.text&#39;</span>
  1048. </pre></div>
  1049. </div>
  1050. </dd>
  1051. <dt id="term-reference-count">reference count<a class="headerlink" href="#term-reference-count" title="Link to this term">¶</a></dt><dd><p>The number of references to an object. When the reference count of an
  1052. object drops to zero, it is deallocated. Some objects are
  1053. “immortal” and have reference counts that are never modified, and
  1054. therefore the objects are never deallocated. Reference counting is
  1055. generally not visible to Python code, but it is a key element of the
  1056. <a class="reference internal" href="#term-CPython"><span class="xref std std-term">CPython</span></a> implementation. Programmers can call the
  1057. <a class="reference internal" href="library/sys.html#sys.getrefcount" title="sys.getrefcount"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getrefcount()</span></code></a> function to return the
  1058. reference count for a particular object.</p>
  1059. </dd>
  1060. <dt id="term-regular-package">regular package<a class="headerlink" href="#term-regular-package" title="Link to this term">¶</a></dt><dd><p>A traditional <a class="reference internal" href="#term-package"><span class="xref std std-term">package</span></a>, such as a directory containing an
  1061. <code class="docutils literal notranslate"><span class="pre">__init__.py</span></code> file.</p>
  1062. <p>See also <a class="reference internal" href="#term-namespace-package"><span class="xref std std-term">namespace package</span></a>.</p>
  1063. </dd>
  1064. <dt id="term-__slots__">__slots__<a class="headerlink" href="#term-__slots__" title="Link to this term">¶</a></dt><dd><p>A declaration inside a class that saves memory by pre-declaring space for
  1065. instance attributes and eliminating instance dictionaries. Though
  1066. popular, the technique is somewhat tricky to get right and is best
  1067. reserved for rare cases where there are large numbers of instances in a
  1068. memory-critical application.</p>
  1069. </dd>
  1070. <dt id="term-sequence">sequence<a class="headerlink" href="#term-sequence" title="Link to this term">¶</a></dt><dd><p>An <a class="reference internal" href="#term-iterable"><span class="xref std std-term">iterable</span></a> which supports efficient element access using integer
  1071. indices via the <a class="reference internal" href="reference/datamodel.html#object.__getitem__" title="object.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a> special method and defines a
  1072. <a class="reference internal" href="reference/datamodel.html#object.__len__" title="object.__len__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__len__()</span></code></a> method that returns the length of the sequence.
  1073. Some built-in sequence types are <a class="reference internal" href="library/stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>, <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>,
  1074. <a class="reference internal" href="library/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>, and <a class="reference internal" href="library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>. Note that <a class="reference internal" href="library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> also
  1075. supports <a class="reference internal" href="reference/datamodel.html#object.__getitem__" title="object.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">__len__()</span></code>, but is considered a
  1076. mapping rather than a sequence because the lookups use arbitrary
  1077. <a class="reference internal" href="#term-immutable"><span class="xref std std-term">immutable</span></a> keys rather than integers.</p>
  1078. <p>The <a class="reference internal" href="library/collections.abc.html#collections.abc.Sequence" title="collections.abc.Sequence"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.Sequence</span></code></a> abstract base class
  1079. defines a much richer interface that goes beyond just
  1080. <a class="reference internal" href="reference/datamodel.html#object.__getitem__" title="object.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a> and <a class="reference internal" href="reference/datamodel.html#object.__len__" title="object.__len__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__len__()</span></code></a>, adding
  1081. <code class="xref py py-meth docutils literal notranslate"><span class="pre">count()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">index()</span></code>, <a class="reference internal" href="reference/datamodel.html#object.__contains__" title="object.__contains__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__contains__()</span></code></a>, and
  1082. <a class="reference internal" href="reference/datamodel.html#object.__reversed__" title="object.__reversed__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__reversed__()</span></code></a>. Types that implement this expanded
  1083. interface can be registered explicitly using
  1084. <a class="reference internal" href="library/abc.html#abc.ABCMeta.register" title="abc.ABCMeta.register"><code class="xref py py-func docutils literal notranslate"><span class="pre">register()</span></code></a>. For more documentation on sequence
  1085. methods generally, see
  1086. <a class="reference internal" href="library/stdtypes.html#typesseq-common"><span class="std std-ref">Common Sequence Operations</span></a>.</p>
  1087. </dd>
  1088. <dt id="term-set-comprehension">set comprehension<a class="headerlink" href="#term-set-comprehension" title="Link to this term">¶</a></dt><dd><p>A compact way to process all or part of the elements in an iterable and
  1089. return a set with the results. <code class="docutils literal notranslate"><span class="pre">results</span> <span class="pre">=</span> <span class="pre">{c</span> <span class="pre">for</span> <span class="pre">c</span> <span class="pre">in</span> <span class="pre">'abracadabra'</span> <span class="pre">if</span>
  1090. <span class="pre">c</span> <span class="pre">not</span> <span class="pre">in</span> <span class="pre">'abc'}</span></code> generates the set of strings <code class="docutils literal notranslate"><span class="pre">{'r',</span> <span class="pre">'d'}</span></code>. See
  1091. <a class="reference internal" href="reference/expressions.html#comprehensions"><span class="std std-ref">Displays for lists, sets and dictionaries</span></a>.</p>
  1092. </dd>
  1093. <dt id="term-single-dispatch">single dispatch<a class="headerlink" href="#term-single-dispatch" title="Link to this term">¶</a></dt><dd><p>A form of <a class="reference internal" href="#term-generic-function"><span class="xref std std-term">generic function</span></a> dispatch where the implementation is
  1094. chosen based on the type of a single argument.</p>
  1095. </dd>
  1096. <dt id="term-slice">slice<a class="headerlink" href="#term-slice" title="Link to this term">¶</a></dt><dd><p>An object usually containing a portion of a <a class="reference internal" href="#term-sequence"><span class="xref std std-term">sequence</span></a>. A slice is
  1097. created using the subscript notation, <code class="docutils literal notranslate"><span class="pre">[]</span></code> with colons between numbers
  1098. when several are given, such as in <code class="docutils literal notranslate"><span class="pre">variable_name[1:3:5]</span></code>. The bracket
  1099. (subscript) notation uses <a class="reference internal" href="library/functions.html#slice" title="slice"><code class="xref py py-class docutils literal notranslate"><span class="pre">slice</span></code></a> objects internally.</p>
  1100. </dd>
  1101. <dt id="term-special-method">special method<a class="headerlink" href="#term-special-method" title="Link to this term">¶</a></dt><dd><p id="index-34">A method that is called implicitly by Python to execute a certain
  1102. operation on a type, such as addition. Such methods have names starting
  1103. and ending with double underscores. Special methods are documented in
  1104. <a class="reference internal" href="reference/datamodel.html#specialnames"><span class="std std-ref">Special method names</span></a>.</p>
  1105. </dd>
  1106. <dt id="term-statement">statement<a class="headerlink" href="#term-statement" title="Link to this term">¶</a></dt><dd><p>A statement is part of a suite (a “block” of code). A statement is either
  1107. an <a class="reference internal" href="#term-expression"><span class="xref std std-term">expression</span></a> or one of several constructs with a keyword, such
  1108. as <a class="reference internal" href="reference/compound_stmts.html#if"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code></a>, <a class="reference internal" href="reference/compound_stmts.html#while"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">while</span></code></a> or <a class="reference internal" href="reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a>.</p>
  1109. </dd>
  1110. <dt id="term-static-type-checker">static type checker<a class="headerlink" href="#term-static-type-checker" title="Link to this term">¶</a></dt><dd><p>An external tool that reads Python code and analyzes it, looking for
  1111. issues such as incorrect types. See also <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hints</span></a>
  1112. and the <a class="reference internal" href="library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module.</p>
  1113. </dd>
  1114. <dt id="term-strong-reference">strong reference<a class="headerlink" href="#term-strong-reference" title="Link to this term">¶</a></dt><dd><p>In Python’s C API, a strong reference is a reference to an object
  1115. which is owned by the code holding the reference. The strong
  1116. reference is taken by calling <a class="reference internal" href="c-api/refcounting.html#c.Py_INCREF" title="Py_INCREF"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_INCREF()</span></code></a> when the
  1117. reference is created and released with <a class="reference internal" href="c-api/refcounting.html#c.Py_DECREF" title="Py_DECREF"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DECREF()</span></code></a>
  1118. when the reference is deleted.</p>
  1119. <p>The <a class="reference internal" href="c-api/refcounting.html#c.Py_NewRef" title="Py_NewRef"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_NewRef()</span></code></a> function can be used to create a strong reference
  1120. to an object. Usually, the <a class="reference internal" href="c-api/refcounting.html#c.Py_DECREF" title="Py_DECREF"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DECREF()</span></code></a> function must be called on
  1121. the strong reference before exiting the scope of the strong reference, to
  1122. avoid leaking one reference.</p>
  1123. <p>See also <a class="reference internal" href="#term-borrowed-reference"><span class="xref std std-term">borrowed reference</span></a>.</p>
  1124. </dd>
  1125. <dt id="term-text-encoding">text encoding<a class="headerlink" href="#term-text-encoding" title="Link to this term">¶</a></dt><dd><p>A string in Python is a sequence of Unicode code points (in range
  1126. <code class="docutils literal notranslate"><span class="pre">U+0000</span></code>–<code class="docutils literal notranslate"><span class="pre">U+10FFFF</span></code>). To store or transfer a string, it needs to be
  1127. serialized as a sequence of bytes.</p>
  1128. <p>Serializing a string into a sequence of bytes is known as “encoding”, and
  1129. recreating the string from the sequence of bytes is known as “decoding”.</p>
  1130. <p>There are a variety of different text serialization
  1131. <a class="reference internal" href="library/codecs.html#standard-encodings"><span class="std std-ref">codecs</span></a>, which are collectively referred to as
  1132. “text encodings”.</p>
  1133. </dd>
  1134. <dt id="term-text-file">text file<a class="headerlink" href="#term-text-file" title="Link to this term">¶</a></dt><dd><p>A <a class="reference internal" href="#term-file-object"><span class="xref std std-term">file object</span></a> able to read and write <a class="reference internal" href="library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> objects.
  1135. Often, a text file actually accesses a byte-oriented datastream
  1136. and handles the <a class="reference internal" href="#term-text-encoding"><span class="xref std std-term">text encoding</span></a> automatically.
  1137. Examples of text files are files opened in text mode (<code class="docutils literal notranslate"><span class="pre">'r'</span></code> or <code class="docutils literal notranslate"><span class="pre">'w'</span></code>),
  1138. <a class="reference internal" href="library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>, <a class="reference internal" href="library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a>, and instances of
  1139. <a class="reference internal" href="library/io.html#io.StringIO" title="io.StringIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.StringIO</span></code></a>.</p>
  1140. <p>See also <a class="reference internal" href="#term-binary-file"><span class="xref std std-term">binary file</span></a> for a file object able to read and write
  1141. <a class="reference internal" href="#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a>.</p>
  1142. </dd>
  1143. <dt id="term-triple-quoted-string">triple-quoted string<a class="headerlink" href="#term-triple-quoted-string" title="Link to this term">¶</a></dt><dd><p>A string which is bound by three instances of either a quotation mark
  1144. (”) or an apostrophe (‘). While they don’t provide any functionality
  1145. not available with single-quoted strings, they are useful for a number
  1146. of reasons. They allow you to include unescaped single and double
  1147. quotes within a string and they can span multiple lines without the
  1148. use of the continuation character, making them especially useful when
  1149. writing docstrings.</p>
  1150. </dd>
  1151. <dt id="term-type">type<a class="headerlink" href="#term-type" title="Link to this term">¶</a></dt><dd><p>The type of a Python object determines what kind of object it is; every
  1152. object has a type. An object’s type is accessible as its
  1153. <a class="reference internal" href="library/stdtypes.html#instance.__class__" title="instance.__class__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__class__</span></code></a> attribute or can be retrieved with
  1154. <code class="docutils literal notranslate"><span class="pre">type(obj)</span></code>.</p>
  1155. </dd>
  1156. <dt id="term-type-alias">type alias<a class="headerlink" href="#term-type-alias" title="Link to this term">¶</a></dt><dd><p>A synonym for a type, created by assigning the type to an identifier.</p>
  1157. <p>Type aliases are useful for simplifying <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hints</span></a>.
  1158. For example:</p>
  1159. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">remove_gray_shades</span><span class="p">(</span>
  1160. <span class="n">colors</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]])</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]]:</span>
  1161. <span class="k">pass</span>
  1162. </pre></div>
  1163. </div>
  1164. <p>could be made more readable like this:</p>
  1165. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">Color</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span>
  1166. <span class="k">def</span> <span class="nf">remove_gray_shades</span><span class="p">(</span><span class="n">colors</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">Color</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Color</span><span class="p">]:</span>
  1167. <span class="k">pass</span>
  1168. </pre></div>
  1169. </div>
  1170. <p>See <a class="reference internal" href="library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> and <span class="target" id="index-35"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>, which describe this functionality.</p>
  1171. </dd>
  1172. <dt id="term-type-hint">type hint<a class="headerlink" href="#term-type-hint" title="Link to this term">¶</a></dt><dd><p>An <a class="reference internal" href="#term-annotation"><span class="xref std std-term">annotation</span></a> that specifies the expected type for a variable, a class
  1173. attribute, or a function parameter or return value.</p>
  1174. <p>Type hints are optional and are not enforced by Python but
  1175. they are useful to <a class="reference internal" href="#term-static-type-checker"><span class="xref std std-term">static type checkers</span></a>.
  1176. They can also aid IDEs with code completion and refactoring.</p>
  1177. <p>Type hints of global variables, class attributes, and functions,
  1178. but not local variables, can be accessed using
  1179. <a class="reference internal" href="library/typing.html#typing.get_type_hints" title="typing.get_type_hints"><code class="xref py py-func docutils literal notranslate"><span class="pre">typing.get_type_hints()</span></code></a>.</p>
  1180. <p>See <a class="reference internal" href="library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> and <span class="target" id="index-36"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>, which describe this functionality.</p>
  1181. </dd>
  1182. <dt id="term-universal-newlines">universal newlines<a class="headerlink" href="#term-universal-newlines" title="Link to this term">¶</a></dt><dd><p>A manner of interpreting text streams in which all of the following are
  1183. recognized as ending a line: the Unix end-of-line convention <code class="docutils literal notranslate"><span class="pre">'\n'</span></code>,
  1184. the Windows convention <code class="docutils literal notranslate"><span class="pre">'\r\n'</span></code>, and the old Macintosh convention
  1185. <code class="docutils literal notranslate"><span class="pre">'\r'</span></code>. See <span class="target" id="index-37"></span><a class="pep reference external" href="https://peps.python.org/pep-0278/"><strong>PEP 278</strong></a> and <span class="target" id="index-38"></span><a class="pep reference external" href="https://peps.python.org/pep-3116/"><strong>PEP 3116</strong></a>, as well as
  1186. <a class="reference internal" href="library/stdtypes.html#bytes.splitlines" title="bytes.splitlines"><code class="xref py py-func docutils literal notranslate"><span class="pre">bytes.splitlines()</span></code></a> for an additional use.</p>
  1187. </dd>
  1188. <dt id="term-variable-annotation">variable annotation<a class="headerlink" href="#term-variable-annotation" title="Link to this term">¶</a></dt><dd><p>An <a class="reference internal" href="#term-annotation"><span class="xref std std-term">annotation</span></a> of a variable or a class attribute.</p>
  1189. <p>When annotating a variable or a class attribute, assignment is optional:</p>
  1190. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
  1191. <span class="n">field</span><span class="p">:</span> <span class="s1">&#39;annotation&#39;</span>
  1192. </pre></div>
  1193. </div>
  1194. <p>Variable annotations are usually used for
  1195. <a class="reference internal" href="#term-type-hint"><span class="xref std std-term">type hints</span></a>: for example this variable is expected to take
  1196. <a class="reference internal" href="library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> values:</p>
  1197. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">count</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
  1198. </pre></div>
  1199. </div>
  1200. <p>Variable annotation syntax is explained in section <a class="reference internal" href="reference/simple_stmts.html#annassign"><span class="std std-ref">Annotated assignment statements</span></a>.</p>
  1201. <p>See <a class="reference internal" href="#term-function-annotation"><span class="xref std std-term">function annotation</span></a>, <span class="target" id="index-39"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a>
  1202. and <span class="target" id="index-40"></span><a class="pep reference external" href="https://peps.python.org/pep-0526/"><strong>PEP 526</strong></a>, which describe this functionality.
  1203. Also see <a class="reference internal" href="howto/annotations.html#annotations-howto"><span class="std std-ref">Annotations Best Practices</span></a>
  1204. for best practices on working with annotations.</p>
  1205. </dd>
  1206. <dt id="term-virtual-environment">virtual environment<a class="headerlink" href="#term-virtual-environment" title="Link to this term">¶</a></dt><dd><p>A cooperatively isolated runtime environment that allows Python users
  1207. and applications to install and upgrade Python distribution packages
  1208. without interfering with the behaviour of other Python applications
  1209. running on the same system.</p>
  1210. <p>See also <a class="reference internal" href="library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a>.</p>
  1211. </dd>
  1212. <dt id="term-virtual-machine">virtual machine<a class="headerlink" href="#term-virtual-machine" title="Link to this term">¶</a></dt><dd><p>A computer defined entirely in software. Python’s virtual machine
  1213. executes the <a class="reference internal" href="#term-bytecode"><span class="xref std std-term">bytecode</span></a> emitted by the bytecode compiler.</p>
  1214. </dd>
  1215. <dt id="term-Zen-of-Python">Zen of Python<a class="headerlink" href="#term-Zen-of-Python" title="Link to this term">¶</a></dt><dd><p>Listing of Python design principles and philosophies that are helpful in
  1216. understanding and using the language. The listing can be found by typing
  1217. “<code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">this</span></code>” at the interactive prompt.</p>
  1218. </dd>
  1219. </dl>
  1220. </section>
  1221. <div class="clearer"></div>
  1222. </div>
  1223. </div>
  1224. </div>
  1225. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  1226. <div class="sphinxsidebarwrapper">
  1227. <div>
  1228. <h4>Previous topic</h4>
  1229. <p class="topless"><a href="faq/installed.html"
  1230. title="previous chapter">“Why is Python Installed on my Computer?” FAQ</a></p>
  1231. </div>
  1232. <div>
  1233. <h4>Next topic</h4>
  1234. <p class="topless"><a href="about.html"
  1235. title="next chapter">About these documents</a></p>
  1236. </div>
  1237. <div role="note" aria-label="source link">
  1238. <h3>This Page</h3>
  1239. <ul class="this-page-menu">
  1240. <li><a href="bugs.html">Report a Bug</a></li>
  1241. <li>
  1242. <a href="https://github.com/python/cpython/blob/main/Doc/glossary.rst"
  1243. rel="nofollow">Show Source
  1244. </a>
  1245. </li>
  1246. </ul>
  1247. </div>
  1248. </div>
  1249. <div id="sidebarbutton" title="Collapse sidebar">
  1250. <span>«</span>
  1251. </div>
  1252. </div>
  1253. <div class="clearer"></div>
  1254. </div>
  1255. <div class="related" role="navigation" aria-label="related navigation">
  1256. <h3>Navigation</h3>
  1257. <ul>
  1258. <li class="right" style="margin-right: 10px">
  1259. <a href="genindex.html" title="General Index"
  1260. >index</a></li>
  1261. <li class="right" >
  1262. <a href="py-modindex.html" title="Python Module Index"
  1263. >modules</a> |</li>
  1264. <li class="right" >
  1265. <a href="about.html" title="About these documents"
  1266. >next</a> |</li>
  1267. <li class="right" >
  1268. <a href="faq/installed.html" title="“Why is Python Installed on my Computer?” FAQ"
  1269. >previous</a> |</li>
  1270. <li><img src="_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  1271. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  1272. <li class="switchers">
  1273. <div class="language_switcher_placeholder"></div>
  1274. <div class="version_switcher_placeholder"></div>
  1275. </li>
  1276. <li>
  1277. </li>
  1278. <li id="cpython-language-and-version">
  1279. <a href="index.html">3.12.3 Documentation</a> &#187;
  1280. </li>
  1281. <li class="nav-item nav-item-this"><a href="">Glossary</a></li>
  1282. <li class="right">
  1283. <div class="inline-search" role="search">
  1284. <form class="inline-search" action="search.html" method="get">
  1285. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  1286. <input type="submit" value="Go" />
  1287. </form>
  1288. </div>
  1289. |
  1290. </li>
  1291. <li class="right">
  1292. <label class="theme-selector-label">
  1293. Theme
  1294. <select class="theme-selector" oninput="activateTheme(this.value)">
  1295. <option value="auto" selected>Auto</option>
  1296. <option value="light">Light</option>
  1297. <option value="dark">Dark</option>
  1298. </select>
  1299. </label> |</li>
  1300. </ul>
  1301. </div>
  1302. <div class="footer">
  1303. &copy;
  1304. <a href="copyright.html">
  1305. Copyright
  1306. </a>
  1307. 2001-2024, Python Software Foundation.
  1308. <br />
  1309. This page is licensed under the Python Software Foundation License Version 2.
  1310. <br />
  1311. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  1312. <br />
  1313. See <a href="/license.html">History and License</a> for more information.<br />
  1314. <br />
  1315. The Python Software Foundation is a non-profit corporation.
  1316. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  1317. <br />
  1318. <br />
  1319. Last updated on Apr 09, 2024 (13:47 UTC).
  1320. <a href="/bugs.html">Found a bug</a>?
  1321. <br />
  1322. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  1323. </div>
  1324. </body>
  1325. </html>
上海开阖软件有限公司 沪ICP备12045867号-1