3.0.html 123 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  6. <meta property="og:title" content="What’s New In Python 3.0" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/whatsnew/3.0.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Author, Guido van Rossum,. This article explains the new features in Python 3.0, compared to 2.6. Python 3.0, also known as “Python 3000” or “Py3K”, is the first ever intentionally backwards incomp..." />
  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="Author, Guido van Rossum,. This article explains the new features in Python 3.0, compared to 2.6. Python 3.0, also known as “Python 3000” or “Py3K”, is the first ever intentionally backwards incomp..." />
  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>What’s New In Python 3.0 &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
  21. <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
  22. <script src="../_static/jquery.js"></script>
  23. <script src="../_static/underscore.js"></script>
  24. <script src="../_static/doctools.js"></script>
  25. <script src="../_static/sidebar.js"></script>
  26. <link rel="search" type="application/opensearchdescription+xml"
  27. title="Search within Python 3.12.0 documentation"
  28. href="../_static/opensearch.xml"/>
  29. <link rel="author" title="About these documents" href="../about.html" />
  30. <link rel="index" title="Index" href="../genindex.html" />
  31. <link rel="search" title="Search" href="../search.html" />
  32. <link rel="copyright" title="Copyright" href="../copyright.html" />
  33. <link rel="next" title="What’s New in Python 2.7" href="2.7.html" />
  34. <link rel="prev" title="What’s New In Python 3.1" href="3.1.html" />
  35. <link rel="canonical" href="https://docs.python.org/3/whatsnew/3.0.html" />
  36. <style>
  37. @media only screen {
  38. table.full-width-table {
  39. width: 100%;
  40. }
  41. }
  42. </style>
  43. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  44. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  45. <script type="text/javascript" src="../_static/copybutton.js"></script>
  46. <script type="text/javascript" src="../_static/menu.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="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. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">What’s New In Python 3.0</a><ul>
  86. <li><a class="reference internal" href="#common-stumbling-blocks">Common Stumbling Blocks</a><ul>
  87. <li><a class="reference internal" href="#print-is-a-function">Print Is A Function</a></li>
  88. <li><a class="reference internal" href="#views-and-iterators-instead-of-lists">Views And Iterators Instead Of Lists</a></li>
  89. <li><a class="reference internal" href="#ordering-comparisons">Ordering Comparisons</a></li>
  90. <li><a class="reference internal" href="#integers">Integers</a></li>
  91. <li><a class="reference internal" href="#text-vs-data-instead-of-unicode-vs-8-bit">Text Vs. Data Instead Of Unicode Vs. 8-bit</a></li>
  92. </ul>
  93. </li>
  94. <li><a class="reference internal" href="#overview-of-syntax-changes">Overview Of Syntax Changes</a><ul>
  95. <li><a class="reference internal" href="#new-syntax">New Syntax</a></li>
  96. <li><a class="reference internal" href="#changed-syntax">Changed Syntax</a></li>
  97. <li><a class="reference internal" href="#removed-syntax">Removed Syntax</a></li>
  98. </ul>
  99. </li>
  100. <li><a class="reference internal" href="#changes-already-present-in-python-2-6">Changes Already Present In Python 2.6</a></li>
  101. <li><a class="reference internal" href="#library-changes">Library Changes</a></li>
  102. <li><a class="reference internal" href="#pep-3101-a-new-approach-to-string-formatting"><strong>PEP 3101</strong>: A New Approach To String Formatting</a></li>
  103. <li><a class="reference internal" href="#changes-to-exceptions">Changes To Exceptions</a></li>
  104. <li><a class="reference internal" href="#miscellaneous-other-changes">Miscellaneous Other Changes</a><ul>
  105. <li><a class="reference internal" href="#operators-and-special-methods">Operators And Special Methods</a></li>
  106. <li><a class="reference internal" href="#builtins">Builtins</a></li>
  107. </ul>
  108. </li>
  109. <li><a class="reference internal" href="#build-and-c-api-changes">Build and C API Changes</a></li>
  110. <li><a class="reference internal" href="#performance">Performance</a></li>
  111. <li><a class="reference internal" href="#porting-to-python-3-0">Porting To Python 3.0</a></li>
  112. </ul>
  113. </li>
  114. </ul>
  115. </div>
  116. <div>
  117. <h4>Previous topic</h4>
  118. <p class="topless"><a href="3.1.html"
  119. title="previous chapter">What’s New In Python 3.1</a></p>
  120. </div>
  121. <div>
  122. <h4>Next topic</h4>
  123. <p class="topless"><a href="2.7.html"
  124. title="next chapter">What’s New in Python 2.7</a></p>
  125. </div>
  126. <div role="note" aria-label="source link">
  127. <h3>This Page</h3>
  128. <ul class="this-page-menu">
  129. <li><a href="../bugs.html">Report a Bug</a></li>
  130. <li>
  131. <a href="https://github.com/python/cpython/blob/main/Doc/whatsnew/3.0.rst"
  132. rel="nofollow">Show Source
  133. </a>
  134. </li>
  135. </ul>
  136. </div>
  137. </nav>
  138. </div>
  139. </div>
  140. <div class="related" role="navigation" aria-label="related navigation">
  141. <h3>Navigation</h3>
  142. <ul>
  143. <li class="right" style="margin-right: 10px">
  144. <a href="../genindex.html" title="General Index"
  145. accesskey="I">index</a></li>
  146. <li class="right" >
  147. <a href="../py-modindex.html" title="Python Module Index"
  148. >modules</a> |</li>
  149. <li class="right" >
  150. <a href="2.7.html" title="What’s New in Python 2.7"
  151. accesskey="N">next</a> |</li>
  152. <li class="right" >
  153. <a href="3.1.html" title="What’s New In Python 3.1"
  154. accesskey="P">previous</a> |</li>
  155. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  156. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  157. <li class="switchers">
  158. <div class="language_switcher_placeholder"></div>
  159. <div class="version_switcher_placeholder"></div>
  160. </li>
  161. <li>
  162. </li>
  163. <li id="cpython-language-and-version">
  164. <a href="../index.html">3.12.0 Documentation</a> &#187;
  165. </li>
  166. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> &#187;</li>
  167. <li class="nav-item nav-item-this"><a href="">What’s New In Python 3.0</a></li>
  168. <li class="right">
  169. <div class="inline-search" role="search">
  170. <form class="inline-search" action="../search.html" method="get">
  171. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  172. <input type="submit" value="Go" />
  173. </form>
  174. </div>
  175. |
  176. </li>
  177. <li class="right">
  178. <label class="theme-selector-label">
  179. Theme
  180. <select class="theme-selector" oninput="activateTheme(this.value)">
  181. <option value="auto" selected>Auto</option>
  182. <option value="light">Light</option>
  183. <option value="dark">Dark</option>
  184. </select>
  185. </label> |</li>
  186. </ul>
  187. </div>
  188. <div class="document">
  189. <div class="documentwrapper">
  190. <div class="bodywrapper">
  191. <div class="body" role="main">
  192. <section id="what-s-new-in-python-3-0">
  193. <h1>What’s New In Python 3.0<a class="headerlink" href="#what-s-new-in-python-3-0" title="Permalink to this headline">¶</a></h1>
  194. <dl class="field-list simple">
  195. <dt class="field-odd">Author</dt>
  196. <dd class="field-odd"><p>Guido van Rossum</p>
  197. </dd>
  198. </dl>
  199. <p>This article explains the new features in Python 3.0, compared to 2.6.
  200. Python 3.0, also known as “Python 3000” or “Py3K”, is the first ever
  201. <em>intentionally backwards incompatible</em> Python release. Python 3.0 was released on December 3, 2008.
  202. There are more changes than in a typical release, and more that are important for all
  203. Python users. Nevertheless, after digesting the changes, you’ll find
  204. that Python really hasn’t changed all that much – by and large, we’re
  205. mostly fixing well-known annoyances and warts, and removing a lot of
  206. old cruft.</p>
  207. <p>This article doesn’t attempt to provide a complete specification of
  208. all new features, but instead tries to give a convenient overview.
  209. For full details, you should refer to the documentation for Python
  210. 3.0, and/or the many PEPs referenced in the text. If you want to
  211. understand the complete implementation and design rationale for a
  212. particular feature, PEPs usually have more details than the regular
  213. documentation; but note that PEPs usually are not kept up-to-date once
  214. a feature has been fully implemented.</p>
  215. <p>Due to time constraints this document is not as complete as it should
  216. have been. As always for a new release, the <code class="docutils literal notranslate"><span class="pre">Misc/NEWS</span></code> file in the
  217. source distribution contains a wealth of detailed information about
  218. every small thing that was changed.</p>
  219. <section id="common-stumbling-blocks">
  220. <h2>Common Stumbling Blocks<a class="headerlink" href="#common-stumbling-blocks" title="Permalink to this headline">¶</a></h2>
  221. <p>This section lists those few changes that are most likely to trip you
  222. up if you’re used to Python 2.5.</p>
  223. <section id="print-is-a-function">
  224. <h3>Print Is A Function<a class="headerlink" href="#print-is-a-function" title="Permalink to this headline">¶</a></h3>
  225. <p>The <code class="docutils literal notranslate"><span class="pre">print</span></code> statement has been replaced with a <a class="reference internal" href="../library/functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a>
  226. function, with keyword arguments to replace most of the special syntax
  227. of the old <code class="docutils literal notranslate"><span class="pre">print</span></code> statement (<span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-3105/"><strong>PEP 3105</strong></a>). Examples:</p>
  228. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">Old</span><span class="p">:</span> <span class="nb">print</span> <span class="s2">&quot;The answer is&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="mi">2</span>
  229. <span class="n">New</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;The answer is&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="mi">2</span><span class="p">)</span>
  230. <span class="n">Old</span><span class="p">:</span> <span class="nb">print</span> <span class="n">x</span><span class="p">,</span> <span class="c1"># Trailing comma suppresses newline</span>
  231. <span class="n">New</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">)</span> <span class="c1"># Appends a space instead of a newline</span>
  232. <span class="n">Old</span><span class="p">:</span> <span class="nb">print</span> <span class="c1"># Prints a newline</span>
  233. <span class="n">New</span><span class="p">:</span> <span class="nb">print</span><span class="p">()</span> <span class="c1"># You must call the function!</span>
  234. <span class="n">Old</span><span class="p">:</span> <span class="nb">print</span> <span class="o">&gt;&gt;</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">,</span> <span class="s2">&quot;fatal error&quot;</span>
  235. <span class="n">New</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;fatal error&quot;</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
  236. <span class="n">Old</span><span class="p">:</span> <span class="nb">print</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="c1"># prints repr((x, y))</span>
  237. <span class="n">New</span><span class="p">:</span> <span class="nb">print</span><span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span> <span class="c1"># Not the same as print(x, y)!</span>
  238. </pre></div>
  239. </div>
  240. <p>You can also customize the separator between items, e.g.:</p>
  241. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;There are &lt;&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="o">**</span><span class="mi">32</span><span class="p">,</span> <span class="s2">&quot;&gt; possibilities!&quot;</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
  242. </pre></div>
  243. </div>
  244. <p>which produces:</p>
  245. <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>There are &lt;4294967296&gt; possibilities!
  246. </pre></div>
  247. </div>
  248. <p>Note:</p>
  249. <ul class="simple">
  250. <li><p>The <a class="reference internal" href="../library/functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a> function doesn’t support the “softspace” feature of
  251. the old <code class="docutils literal notranslate"><span class="pre">print</span></code> statement. For example, in Python 2.x,
  252. <code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">&quot;A\n&quot;,</span> <span class="pre">&quot;B&quot;</span></code> would write <code class="docutils literal notranslate"><span class="pre">&quot;A\nB\n&quot;</span></code>; but in Python 3.0,
  253. <code class="docutils literal notranslate"><span class="pre">print(&quot;A\n&quot;,</span> <span class="pre">&quot;B&quot;)</span></code> writes <code class="docutils literal notranslate"><span class="pre">&quot;A\n</span> <span class="pre">B\n&quot;</span></code>.</p></li>
  254. <li><p>Initially, you’ll be finding yourself typing the old <code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">x</span></code>
  255. a lot in interactive mode. Time to retrain your fingers to type
  256. <code class="docutils literal notranslate"><span class="pre">print(x)</span></code> instead!</p></li>
  257. <li><p>When using the <code class="docutils literal notranslate"><span class="pre">2to3</span></code> source-to-source conversion tool, all
  258. <code class="docutils literal notranslate"><span class="pre">print</span></code> statements are automatically converted to
  259. <a class="reference internal" href="../library/functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a> function calls, so this is mostly a non-issue for
  260. larger projects.</p></li>
  261. </ul>
  262. </section>
  263. <section id="views-and-iterators-instead-of-lists">
  264. <h3>Views And Iterators Instead Of Lists<a class="headerlink" href="#views-and-iterators-instead-of-lists" title="Permalink to this headline">¶</a></h3>
  265. <p>Some well-known APIs no longer return lists:</p>
  266. <ul>
  267. <li><p><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> methods <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.items" title="dict.items"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.items()</span></code></a> and
  268. <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> return “views” instead of lists. For example,
  269. this no longer works: <code class="docutils literal notranslate"><span class="pre">k</span> <span class="pre">=</span> <span class="pre">d.keys();</span> <span class="pre">k.sort()</span></code>. Use <code class="docutils literal notranslate"><span class="pre">k</span> <span class="pre">=</span>
  270. <span class="pre">sorted(d)</span></code> instead (this works in Python 2.5 too and is just
  271. as efficient).</p></li>
  272. <li><p>Also, the <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.iterkeys()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.iteritems()</span></code> and
  273. <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.itervalues()</span></code> methods are no longer supported.</p></li>
  274. <li><p><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> and <a class="reference internal" href="../library/functions.html#filter" title="filter"><code class="xref py py-func docutils literal notranslate"><span class="pre">filter()</span></code></a> return iterators. If you really need
  275. a list and the input sequences are all of equal length, a quick
  276. fix is to wrap <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> in <a class="reference internal" href="../library/stdtypes.html#list" title="list"><code class="xref py py-func docutils literal notranslate"><span class="pre">list()</span></code></a>, e.g. <code class="docutils literal notranslate"><span class="pre">list(map(...))</span></code>,
  277. but a better fix is
  278. often to use a list comprehension (especially when the original code
  279. uses <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>), or rewriting the code so it doesn’t need a
  280. list at all. Particularly tricky is <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> invoked for the
  281. side effects of the function; the correct transformation is to use a
  282. regular <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 (since creating a list would just be
  283. wasteful).</p>
  284. <p>If the input sequences are not of equal length, <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> will
  285. stop at the termination of the shortest of the sequences. For full
  286. compatibility with <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> from Python 2.x, also wrap the sequences in
  287. <a class="reference internal" href="../library/itertools.html#itertools.zip_longest" title="itertools.zip_longest"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.zip_longest()</span></code></a>, e.g. <code class="docutils literal notranslate"><span class="pre">map(func,</span> <span class="pre">*sequences)</span></code> becomes
  288. <code class="docutils literal notranslate"><span class="pre">list(map(func,</span> <span class="pre">itertools.zip_longest(*sequences)))</span></code>.</p>
  289. </li>
  290. <li><p><a class="reference internal" href="../library/stdtypes.html#range" title="range"><code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code></a> now behaves like <code class="xref py py-func docutils literal notranslate"><span class="pre">xrange()</span></code> used to behave, except
  291. it works with values of arbitrary size. The latter no longer
  292. exists.</p></li>
  293. <li><p><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> now returns an iterator.</p></li>
  294. </ul>
  295. </section>
  296. <section id="ordering-comparisons">
  297. <h3>Ordering Comparisons<a class="headerlink" href="#ordering-comparisons" title="Permalink to this headline">¶</a></h3>
  298. <p>Python 3.0 has simplified the rules for ordering comparisons:</p>
  299. <ul class="simple">
  300. <li><p>The ordering comparison operators (<code class="docutils literal notranslate"><span class="pre">&lt;</span></code>, <code class="docutils literal notranslate"><span class="pre">&lt;=</span></code>, <code class="docutils literal notranslate"><span class="pre">&gt;=</span></code>, <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>)
  301. raise a TypeError exception when the operands don’t have a
  302. meaningful natural ordering. Thus, expressions like <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">&lt;</span> <span class="pre">''</span></code>, <code class="docutils literal notranslate"><span class="pre">0</span>
  303. <span class="pre">&gt;</span> <span class="pre">None</span></code> or <code class="docutils literal notranslate"><span class="pre">len</span> <span class="pre">&lt;=</span> <span class="pre">len</span></code> are no longer valid, and e.g. <code class="docutils literal notranslate"><span class="pre">None</span> <span class="pre">&lt;</span>
  304. <span class="pre">None</span></code> raises <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> instead of returning
  305. <code class="docutils literal notranslate"><span class="pre">False</span></code>. A corollary is that sorting a heterogeneous list
  306. no longer makes sense – all the elements must be comparable to each
  307. other. Note that this does not apply to the <code class="docutils literal notranslate"><span class="pre">==</span></code> and <code class="docutils literal notranslate"><span class="pre">!=</span></code>
  308. operators: objects of different incomparable types always compare
  309. unequal to each other.</p></li>
  310. <li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">builtin.sorted()</span></code> and <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> no longer accept the
  311. <em>cmp</em> argument providing a comparison function. Use the <em>key</em>
  312. argument instead. N.B. the <em>key</em> and <em>reverse</em> arguments are now
  313. “keyword-only”.</p></li>
  314. <li><p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">cmp()</span></code> function should be treated as gone, and the <code class="xref py py-meth docutils literal notranslate"><span class="pre">__cmp__()</span></code>
  315. special method is no longer supported. Use <code class="xref py py-meth docutils literal notranslate"><span class="pre">__lt__()</span></code> for sorting,
  316. <code class="xref py py-meth docutils literal notranslate"><span class="pre">__eq__()</span></code> with <code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code>, and other rich comparisons as needed.
  317. (If you really need the <code class="xref py py-func docutils literal notranslate"><span class="pre">cmp()</span></code> functionality, you could use the
  318. expression <code class="docutils literal notranslate"><span class="pre">(a</span> <span class="pre">&gt;</span> <span class="pre">b)</span> <span class="pre">-</span> <span class="pre">(a</span> <span class="pre">&lt;</span> <span class="pre">b)</span></code> as the equivalent for <code class="docutils literal notranslate"><span class="pre">cmp(a,</span> <span class="pre">b)</span></code>.)</p></li>
  319. </ul>
  320. </section>
  321. <section id="integers">
  322. <h3>Integers<a class="headerlink" href="#integers" title="Permalink to this headline">¶</a></h3>
  323. <ul class="simple">
  324. <li><p><span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0237/"><strong>PEP 237</strong></a>: Essentially, <code class="xref py py-class docutils literal notranslate"><span class="pre">long</span></code> renamed to <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>.
  325. That is, there is only one built-in integral type, named
  326. <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>; but it behaves mostly like the old <code class="xref py py-class docutils literal notranslate"><span class="pre">long</span></code> type.</p></li>
  327. <li><p><span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0238/"><strong>PEP 238</strong></a>: An expression like <code class="docutils literal notranslate"><span class="pre">1/2</span></code> returns a float. Use
  328. <code class="docutils literal notranslate"><span class="pre">1//2</span></code> to get the truncating behavior. (The latter syntax has
  329. existed for years, at least since Python 2.2.)</p></li>
  330. <li><p>The <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxint</span></code> constant was removed, since there is no
  331. longer a limit to the value of integers. However, <a class="reference internal" href="../library/sys.html#sys.maxsize" title="sys.maxsize"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxsize</span></code></a>
  332. can be used as an integer larger than any practical list or string
  333. index. It conforms to the implementation’s “natural” integer size
  334. and is typically the same as <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxint</span></code> in previous releases
  335. on the same platform (assuming the same build options).</p></li>
  336. <li><p>The <a class="reference internal" href="../library/functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> of a long integer doesn’t include the trailing <code class="docutils literal notranslate"><span class="pre">L</span></code>
  337. anymore, so code that unconditionally strips that character will
  338. chop off the last digit instead. (Use <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-func docutils literal notranslate"><span class="pre">str()</span></code></a> instead.)</p></li>
  339. <li><p>Octal literals are no longer of the form <code class="docutils literal notranslate"><span class="pre">0720</span></code>; use <code class="docutils literal notranslate"><span class="pre">0o720</span></code>
  340. instead.</p></li>
  341. </ul>
  342. </section>
  343. <section id="text-vs-data-instead-of-unicode-vs-8-bit">
  344. <h3>Text Vs. Data Instead Of Unicode Vs. 8-bit<a class="headerlink" href="#text-vs-data-instead-of-unicode-vs-8-bit" title="Permalink to this headline">¶</a></h3>
  345. <p>Everything you thought you knew about binary data and Unicode has
  346. changed.</p>
  347. <ul class="simple">
  348. <li><p>Python 3.0 uses the concepts of <em>text</em> and (binary) <em>data</em> instead
  349. of Unicode strings and 8-bit strings. All text is Unicode; however
  350. <em>encoded</em> Unicode is represented as binary data. The type used to
  351. hold text is <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>, the type used to hold data is
  352. <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>. The biggest difference with the 2.x situation is
  353. that any attempt to mix text and data in Python 3.0 raises
  354. <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>, whereas if you were to mix Unicode and 8-bit
  355. strings in Python 2.x, it would work if the 8-bit string happened to
  356. contain only 7-bit (ASCII) bytes, but you would get
  357. <a class="reference internal" href="../library/exceptions.html#UnicodeDecodeError" title="UnicodeDecodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeDecodeError</span></code></a> if it contained non-ASCII values. This
  358. value-specific behavior has caused numerous sad faces over the
  359. years.</p></li>
  360. <li><p>As a consequence of this change in philosophy, pretty much all code
  361. that uses Unicode, encodings or binary data most likely has to
  362. change. The change is for the better, as in the 2.x world there
  363. were numerous bugs having to do with mixing encoded and unencoded
  364. text. To be prepared in Python 2.x, start using <code class="xref py py-class docutils literal notranslate"><span class="pre">unicode</span></code>
  365. for all unencoded text, and <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> for binary or encoded data
  366. only. Then the <code class="docutils literal notranslate"><span class="pre">2to3</span></code> tool will do most of the work for you.</p></li>
  367. <li><p>You can no longer use <code class="docutils literal notranslate"><span class="pre">u&quot;...&quot;</span></code> literals for Unicode text.
  368. However, you must use <code class="docutils literal notranslate"><span class="pre">b&quot;...&quot;</span></code> literals for binary data.</p></li>
  369. <li><p>As the <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> 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> types cannot be mixed, you
  370. must always explicitly convert between them. Use <a class="reference internal" href="../library/stdtypes.html#str.encode" title="str.encode"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.encode()</span></code></a>
  371. to go from <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> to <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 class="reference internal" href="../library/stdtypes.html#bytes.decode" title="bytes.decode"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytes.decode()</span></code></a>
  372. to go from <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> to <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>. You can also use
  373. <code class="docutils literal notranslate"><span class="pre">bytes(s,</span> <span class="pre">encoding=...)</span></code> and <code class="docutils literal notranslate"><span class="pre">str(b,</span> <span class="pre">encoding=...)</span></code>,
  374. respectively.</p></li>
  375. <li><p>Like <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>, the <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> type is immutable. There is a
  376. separate <em>mutable</em> type to hold buffered binary data,
  377. <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>. Nearly all APIs that accept <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> also
  378. accept <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>. The mutable API is based on
  379. <code class="xref py py-class docutils literal notranslate"><span class="pre">collections.MutableSequence</span></code>.</p></li>
  380. <li><p>All backslashes in raw string literals are interpreted literally.
  381. This means that <code class="docutils literal notranslate"><span class="pre">'\U'</span></code> and <code class="docutils literal notranslate"><span class="pre">'\u'</span></code> escapes in raw strings are not
  382. treated specially. For example, <code class="docutils literal notranslate"><span class="pre">r'\u20ac'</span></code> is a string of 6
  383. characters in Python 3.0, whereas in 2.6, <code class="docutils literal notranslate"><span class="pre">ur'\u20ac'</span></code> was the
  384. single “euro” character. (Of course, this change only affects raw
  385. string literals; the euro character is <code class="docutils literal notranslate"><span class="pre">'\u20ac'</span></code> in Python 3.0.)</p></li>
  386. <li><p>The built-in <code class="xref py py-class docutils literal notranslate"><span class="pre">basestring</span></code> abstract type was removed. Use
  387. <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> instead. The <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> 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> types
  388. don’t have functionality enough in common to warrant a shared base
  389. class. The <code class="docutils literal notranslate"><span class="pre">2to3</span></code> tool (see below) replaces every occurrence of
  390. <code class="xref py py-class docutils literal notranslate"><span class="pre">basestring</span></code> with <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>.</p></li>
  391. <li><p>Files opened as text files (still the default mode for <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>)
  392. always use an encoding to map between strings (in memory) and bytes
  393. (on disk). Binary files (opened with a <code class="docutils literal notranslate"><span class="pre">b</span></code> in the mode argument)
  394. always use bytes in memory. This means that if a file is opened
  395. using an incorrect mode or encoding, I/O will likely fail loudly,
  396. instead of silently producing incorrect data. It also means that
  397. even Unix users will have to specify the correct mode (text or
  398. binary) when opening a file. There is a platform-dependent default
  399. encoding, which on Unixy platforms can be set with the <code class="docutils literal notranslate"><span class="pre">LANG</span></code>
  400. environment variable (and sometimes also with some other
  401. platform-specific locale-related environment variables). In many
  402. cases, but not all, the system default is UTF-8; you should never
  403. count on this default. Any application reading or writing more than
  404. pure ASCII text should probably have a way to override the encoding.
  405. There is no longer any need for using the encoding-aware streams
  406. in the <a class="reference internal" href="../library/codecs.html#module-codecs" title="codecs: Encode and decode data and streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">codecs</span></code></a> module.</p></li>
  407. <li><p>The initial values of <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
  408. <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a> are now unicode-only text files (i.e., they are
  409. instances of <a class="reference internal" href="../library/io.html#io.TextIOBase" title="io.TextIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOBase</span></code></a>). To read and write bytes data
  410. with these streams, you need to use their <a class="reference internal" href="../library/io.html#io.TextIOBase.buffer" title="io.TextIOBase.buffer"><code class="xref py py-data docutils literal notranslate"><span class="pre">io.TextIOBase.buffer</span></code></a>
  411. attribute.</p></li>
  412. <li><p>Filenames are passed to and returned from APIs as (Unicode) strings.
  413. This can present platform-specific problems because on some
  414. platforms filenames are arbitrary byte strings. (On the other hand,
  415. on Windows filenames are natively stored as Unicode.) As a
  416. work-around, most APIs (e.g. <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> and many functions in the
  417. <a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> module) that take filenames accept <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> objects
  418. as well as strings, and a few APIs have a way to ask for a
  419. <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> return value. Thus, <a class="reference internal" href="../library/os.html#os.listdir" title="os.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.listdir()</span></code></a> returns a
  420. list of <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> instances if the argument is 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>
  421. instance, and <a class="reference internal" href="../library/os.html#os.getcwdb" title="os.getcwdb"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.getcwdb()</span></code></a> returns the current working
  422. directory as 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> instance. Note that when
  423. <a class="reference internal" href="../library/os.html#os.listdir" title="os.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.listdir()</span></code></a> returns a list of strings, filenames that
  424. cannot be decoded properly are omitted rather than raising
  425. <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></li>
  426. <li><p>Some system APIs like <a class="reference internal" href="../library/os.html#os.environ" title="os.environ"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.environ</span></code></a> and <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> can
  427. also present problems when the bytes made available by the system is
  428. not interpretable using the default encoding. Setting the <code class="docutils literal notranslate"><span class="pre">LANG</span></code>
  429. variable and rerunning the program is probably the best approach.</p></li>
  430. <li><p><span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-3138/"><strong>PEP 3138</strong></a>: The <a class="reference internal" href="../library/functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> of a string no longer escapes
  431. non-ASCII characters. It still escapes control characters and code
  432. points with non-printable status in the Unicode standard, however.</p></li>
  433. <li><p><span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-3120/"><strong>PEP 3120</strong></a>: The default source encoding is now UTF-8.</p></li>
  434. <li><p><span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-3131/"><strong>PEP 3131</strong></a>: Non-ASCII letters are now allowed in identifiers.
  435. (However, the standard library remains ASCII-only with the exception
  436. of contributor names in comments.)</p></li>
  437. <li><p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">StringIO</span></code> and <code class="xref py py-mod docutils literal notranslate"><span class="pre">cStringIO</span></code> modules are gone. Instead,
  438. import 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 and use <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> or
  439. <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> for text and data respectively.</p></li>
  440. <li><p>See also the <a class="reference internal" href="../howto/unicode.html#unicode-howto"><span class="std std-ref">Unicode HOWTO</span></a>, which was updated for Python 3.0.</p></li>
  441. </ul>
  442. </section>
  443. </section>
  444. <section id="overview-of-syntax-changes">
  445. <h2>Overview Of Syntax Changes<a class="headerlink" href="#overview-of-syntax-changes" title="Permalink to this headline">¶</a></h2>
  446. <p>This section gives a brief overview of every <em>syntactic</em> change in
  447. Python 3.0.</p>
  448. <section id="new-syntax">
  449. <h3>New Syntax<a class="headerlink" href="#new-syntax" title="Permalink to this headline">¶</a></h3>
  450. <ul>
  451. <li><p><span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-3107/"><strong>PEP 3107</strong></a>: Function argument and return value annotations. This
  452. provides a standardized way of annotating a function’s parameters
  453. and return value. There are no semantics attached to such
  454. annotations except that they can be introspected at runtime using
  455. the <code class="xref py py-attr docutils literal notranslate"><span class="pre">__annotations__</span></code> attribute. The intent is to encourage
  456. experimentation through metaclasses, decorators or frameworks.</p></li>
  457. <li><p><span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-3102/"><strong>PEP 3102</strong></a>: Keyword-only arguments. Named parameters occurring
  458. after <code class="docutils literal notranslate"><span class="pre">*args</span></code> in the parameter list <em>must</em> be specified using
  459. keyword syntax in the call. You can also use a bare <code class="docutils literal notranslate"><span class="pre">*</span></code> in the
  460. parameter list to indicate that you don’t accept a variable-length
  461. argument list, but you do have keyword-only arguments.</p></li>
  462. <li><p>Keyword arguments are allowed after the list of base classes in a
  463. class definition. This is used by the new convention for specifying
  464. a metaclass (see next section), but can be used for other purposes
  465. as well, as long as the metaclass supports it.</p></li>
  466. <li><p><span class="target" id="index-8"></span><a class="pep reference external" href="https://peps.python.org/pep-3104/"><strong>PEP 3104</strong></a>: <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> statement. Using <code class="docutils literal notranslate"><span class="pre">nonlocal</span> <span class="pre">x</span></code>
  467. you can now assign directly to a variable in an outer (but
  468. non-global) scope. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">nonlocal</span></code> is a new reserved word.</p></li>
  469. <li><p><span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-3132/"><strong>PEP 3132</strong></a>: Extended Iterable Unpacking. You can now write things
  470. like <code class="docutils literal notranslate"><span class="pre">a,</span> <span class="pre">b,</span> <span class="pre">*rest</span> <span class="pre">=</span> <span class="pre">some_sequence</span></code>. And even <code class="docutils literal notranslate"><span class="pre">*rest,</span> <span class="pre">a</span> <span class="pre">=</span>
  471. <span class="pre">stuff</span></code>. The <code class="docutils literal notranslate"><span class="pre">rest</span></code> object is always a (possibly empty) list; the
  472. right-hand side may be any iterable. Example:</p>
  473. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
  474. </pre></div>
  475. </div>
  476. <p>This sets <em>a</em> to <code class="docutils literal notranslate"><span class="pre">0</span></code>, <em>b</em> to <code class="docutils literal notranslate"><span class="pre">4</span></code>, and <em>rest</em> to <code class="docutils literal notranslate"><span class="pre">[1,</span> <span class="pre">2,</span> <span class="pre">3]</span></code>.</p>
  477. </li>
  478. <li><p>Dictionary comprehensions: <code class="docutils literal notranslate"><span class="pre">{k:</span> <span class="pre">v</span> <span class="pre">for</span> <span class="pre">k,</span> <span class="pre">v</span> <span class="pre">in</span> <span class="pre">stuff}</span></code> means the
  479. same thing as <code class="docutils literal notranslate"><span class="pre">dict(stuff)</span></code> but is more flexible. (This is
  480. <span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-0274/"><strong>PEP 274</strong></a> vindicated. :-)</p></li>
  481. <li><p>Set literals, e.g. <code class="docutils literal notranslate"><span class="pre">{1,</span> <span class="pre">2}</span></code>. Note that <code class="docutils literal notranslate"><span class="pre">{}</span></code> is an empty
  482. dictionary; use <code class="docutils literal notranslate"><span class="pre">set()</span></code> for an empty set. Set comprehensions are
  483. also supported; e.g., <code class="docutils literal notranslate"><span class="pre">{x</span> <span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">stuff}</span></code> means the same thing as
  484. <code class="docutils literal notranslate"><span class="pre">set(stuff)</span></code> but is more flexible.</p></li>
  485. <li><p>New octal literals, e.g. <code class="docutils literal notranslate"><span class="pre">0o720</span></code> (already in 2.6). The old octal
  486. literals (<code class="docutils literal notranslate"><span class="pre">0720</span></code>) are gone.</p></li>
  487. <li><p>New binary literals, e.g. <code class="docutils literal notranslate"><span class="pre">0b1010</span></code> (already in 2.6), and
  488. there is a new corresponding built-in function, <a class="reference internal" href="../library/functions.html#bin" title="bin"><code class="xref py py-func docutils literal notranslate"><span class="pre">bin()</span></code></a>.</p></li>
  489. <li><p>Bytes literals are introduced with a leading <code class="docutils literal notranslate"><span class="pre">b</span></code> or <code class="docutils literal notranslate"><span class="pre">B</span></code>, and
  490. there is a new corresponding built-in function, <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-func docutils literal notranslate"><span class="pre">bytes()</span></code></a>.</p></li>
  491. </ul>
  492. </section>
  493. <section id="changed-syntax">
  494. <h3>Changed Syntax<a class="headerlink" href="#changed-syntax" title="Permalink to this headline">¶</a></h3>
  495. <ul>
  496. <li><p><span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-3109/"><strong>PEP 3109</strong></a> and <span class="target" id="index-12"></span><a class="pep reference external" href="https://peps.python.org/pep-3134/"><strong>PEP 3134</strong></a>: new <a class="reference internal" href="../reference/simple_stmts.html#raise"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">raise</span></code></a> statement syntax:
  497. <code class="samp docutils literal notranslate"><span class="pre">raise</span> <span class="pre">[</span><em><span class="pre">expr</span></em> <span class="pre">[from</span> <em><span class="pre">expr</span></em><span class="pre">]]</span></code>. See below.</p></li>
  498. <li><p><code class="xref std std-keyword docutils literal notranslate"><span class="pre">as</span></code> and <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> are now reserved words. (Since
  499. 2.6, actually.)</p></li>
  500. <li><p><code class="docutils literal notranslate"><span class="pre">True</span></code>, <code class="docutils literal notranslate"><span class="pre">False</span></code>, and <code class="docutils literal notranslate"><span class="pre">None</span></code> are reserved words. (2.6 partially enforced
  501. the restrictions on <code class="docutils literal notranslate"><span class="pre">None</span></code> already.)</p></li>
  502. <li><p>Change from <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> <em>exc</em>, <em>var</em> to
  503. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">except</span></code> <em>exc</em> <code class="xref std std-keyword docutils literal notranslate"><span class="pre">as</span></code> <em>var</em>. See <span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-3110/"><strong>PEP 3110</strong></a>.</p></li>
  504. <li><p><span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-3115/"><strong>PEP 3115</strong></a>: New Metaclass Syntax. Instead of:</p>
  505. <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>
  506. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">M</span>
  507. <span class="o">...</span>
  508. </pre></div>
  509. </div>
  510. <p>you must now use:</p>
  511. <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><span class="n">metaclass</span><span class="o">=</span><span class="n">M</span><span class="p">):</span>
  512. <span class="o">...</span>
  513. </pre></div>
  514. </div>
  515. <p>The module-global <code class="xref py py-data docutils literal notranslate"><span class="pre">__metaclass__</span></code> variable is no longer
  516. supported. (It was a crutch to make it easier to default to
  517. new-style classes without deriving every class from
  518. <a class="reference internal" href="../library/functions.html#object" title="object"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a>.)</p>
  519. </li>
  520. <li><p>List comprehensions no longer support the syntactic form
  521. <code class="samp docutils literal notranslate"><span class="pre">[...</span> <span class="pre">for</span> <em><span class="pre">var</span></em> <span class="pre">in</span> <em><span class="pre">item1</span></em><span class="pre">,</span> <em><span class="pre">item2</span></em><span class="pre">,</span> <span class="pre">...]</span></code>. Use
  522. <code class="samp docutils literal notranslate"><span class="pre">[...</span> <span class="pre">for</span> <em><span class="pre">var</span></em> <span class="pre">in</span> <span class="pre">(</span><em><span class="pre">item1</span></em><span class="pre">,</span> <em><span class="pre">item2</span></em><span class="pre">,</span> <span class="pre">...)]</span></code> instead.
  523. Also note that list comprehensions have different semantics: they
  524. are closer to syntactic sugar for a generator expression inside a
  525. <a class="reference internal" href="../library/stdtypes.html#list" title="list"><code class="xref py py-func docutils literal notranslate"><span class="pre">list()</span></code></a> constructor, and in particular the loop control
  526. variables are no longer leaked into the surrounding scope.</p></li>
  527. <li><p>The <em>ellipsis</em> (<code class="docutils literal notranslate"><span class="pre">...</span></code>) can be used as an atomic expression
  528. anywhere. (Previously it was only allowed in slices.) Also, it
  529. <em>must</em> now be spelled as <code class="docutils literal notranslate"><span class="pre">...</span></code>. (Previously it could also be
  530. spelled as <code class="docutils literal notranslate"><span class="pre">.</span> <span class="pre">.</span> <span class="pre">.</span></code>, by a mere accident of the grammar.)</p></li>
  531. </ul>
  532. </section>
  533. <section id="removed-syntax">
  534. <h3>Removed Syntax<a class="headerlink" href="#removed-syntax" title="Permalink to this headline">¶</a></h3>
  535. <ul class="simple">
  536. <li><p><span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-3113/"><strong>PEP 3113</strong></a>: Tuple parameter unpacking removed. You can no longer
  537. write <code class="docutils literal notranslate"><span class="pre">def</span> <span class="pre">foo(a,</span> <span class="pre">(b,</span> <span class="pre">c)):</span> <span class="pre">...</span></code>.
  538. Use <code class="docutils literal notranslate"><span class="pre">def</span> <span class="pre">foo(a,</span> <span class="pre">b_c):</span> <span class="pre">b,</span> <span class="pre">c</span> <span class="pre">=</span> <span class="pre">b_c</span></code> instead.</p></li>
  539. <li><p>Removed backticks (use <a class="reference internal" href="../library/functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> instead).</p></li>
  540. <li><p>Removed <code class="docutils literal notranslate"><span class="pre">&lt;&gt;</span></code> (use <code class="docutils literal notranslate"><span class="pre">!=</span></code> instead).</p></li>
  541. <li><p>Removed keyword: <a class="reference internal" href="../library/functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> is no longer a keyword; it remains as
  542. a function. (Fortunately the function syntax was also accepted in
  543. 2.x.) Also note that <a class="reference internal" href="../library/functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> no longer takes a stream argument;
  544. instead of <code class="docutils literal notranslate"><span class="pre">exec(f)</span></code> you can use <code class="docutils literal notranslate"><span class="pre">exec(f.read())</span></code>.</p></li>
  545. <li><p>Integer literals no longer support a trailing <code class="docutils literal notranslate"><span class="pre">l</span></code> or <code class="docutils literal notranslate"><span class="pre">L</span></code>.</p></li>
  546. <li><p>String literals no longer support a leading <code class="docutils literal notranslate"><span class="pre">u</span></code> or <code class="docutils literal notranslate"><span class="pre">U</span></code>.</p></li>
  547. <li><p>The <a class="reference internal" href="../reference/simple_stmts.html#from"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">from</span></code></a> <em>module</em> <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> <code class="docutils literal notranslate"><span class="pre">*</span></code> syntax is only
  548. allowed at the module level, no longer inside functions.</p></li>
  549. <li><p>The only acceptable syntax for relative imports is <code class="samp docutils literal notranslate"><span class="pre">from</span> <span class="pre">.[</span><em><span class="pre">module</span></em><span class="pre">]</span>
  550. <span class="pre">import</span> <em><span class="pre">name</span></em></code>. All <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> forms not starting with <code class="docutils literal notranslate"><span class="pre">.</span></code> are
  551. interpreted as absolute imports. (<span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0328/"><strong>PEP 328</strong></a>)</p></li>
  552. <li><p>Classic classes are gone.</p></li>
  553. </ul>
  554. </section>
  555. </section>
  556. <section id="changes-already-present-in-python-2-6">
  557. <h2>Changes Already Present In Python 2.6<a class="headerlink" href="#changes-already-present-in-python-2-6" title="Permalink to this headline">¶</a></h2>
  558. <p>Since many users presumably make the jump straight from Python 2.5 to
  559. Python 3.0, this section reminds the reader of new features that were
  560. originally designed for Python 3.0 but that were back-ported to Python
  561. 2.6. The corresponding sections in <a class="reference internal" href="2.6.html#whats-new-in-2-6"><span class="std std-ref">What’s New in Python 2.6</span></a> should be
  562. consulted for longer descriptions.</p>
  563. <ul class="simple">
  564. <li><p><a class="reference internal" href="2.6.html#pep-0343"><span class="std std-ref">PEP 343: The ‘with’ statement</span></a>. The <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> statement is now a standard
  565. feature and no longer needs to be imported from 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>.
  566. Also check out <a class="reference internal" href="2.6.html#new-26-context-managers"><span class="std std-ref">Writing Context Managers</span></a> and
  567. <a class="reference internal" href="2.6.html#new-module-contextlib"><span class="std std-ref">The contextlib module</span></a>.</p></li>
  568. <li><p><a class="reference internal" href="2.6.html#pep-0366"><span class="std std-ref">PEP 366: Explicit Relative Imports From a Main Module</span></a>. This enhances the usefulness of the <a class="reference internal" href="../using/cmdline.html#cmdoption-m"><code class="xref std std-option docutils literal notranslate"><span class="pre">-m</span></code></a>
  569. option when the referenced module lives in a package.</p></li>
  570. <li><p><a class="reference internal" href="2.6.html#pep-0370"><span class="std std-ref">PEP 370: Per-user site-packages Directory</span></a>.</p></li>
  571. <li><p><a class="reference internal" href="2.6.html#pep-0371"><span class="std std-ref">PEP 371: The multiprocessing Package</span></a>.</p></li>
  572. <li><p><a class="reference internal" href="2.6.html#pep-3101"><span class="std std-ref">PEP 3101: Advanced String Formatting</span></a>. Note: the 2.6 description mentions the
  573. <a class="reference internal" href="../library/functions.html#format" title="format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">format()</span></code></a> method for both 8-bit and Unicode strings. In 3.0,
  574. only the <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> type (text strings with Unicode support)
  575. supports this method; the <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> type does not. The plan is
  576. to eventually make this the only API for string formatting, and to
  577. start deprecating the <code class="docutils literal notranslate"><span class="pre">%</span></code> operator in Python 3.1.</p></li>
  578. <li><p><a class="reference internal" href="2.6.html#pep-3105"><span class="std std-ref">PEP 3105: print As a Function</span></a>. This is now a standard feature and no longer needs
  579. to be imported from <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>. More details were given above.</p></li>
  580. <li><p><a class="reference internal" href="2.6.html#pep-3110"><span class="std std-ref">PEP 3110: Exception-Handling Changes</span></a>. The <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> <em>exc</em> <code class="xref std std-keyword docutils literal notranslate"><span class="pre">as</span></code> <em>var</em>
  581. syntax is now standard and <code class="xref std std-keyword docutils literal notranslate"><span class="pre">except</span></code> <em>exc</em>, <em>var</em> is no
  582. longer supported. (Of course, the <code class="xref std std-keyword docutils literal notranslate"><span class="pre">as</span></code> <em>var</em> part is still
  583. optional.)</p></li>
  584. <li><p><a class="reference internal" href="2.6.html#pep-3112"><span class="std std-ref">PEP 3112: Byte Literals</span></a>. The <code class="docutils literal notranslate"><span class="pre">b&quot;...&quot;</span></code> string literal notation (and its
  585. variants like <code class="docutils literal notranslate"><span class="pre">b'...'</span></code>, <code class="docutils literal notranslate"><span class="pre">b&quot;&quot;&quot;...&quot;&quot;&quot;</span></code>, and <code class="docutils literal notranslate"><span class="pre">br&quot;...&quot;</span></code>) now
  586. produces a literal of type <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>.</p></li>
  587. <li><p><a class="reference internal" href="2.6.html#pep-3116"><span class="std std-ref">PEP 3116: New I/O Library</span></a>. 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 is now the standard way of
  588. doing file I/O. The built-in <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 is now an
  589. alias for <a class="reference internal" href="../library/io.html#io.open" title="io.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">io.open()</span></code></a> and has additional keyword arguments
  590. <em>encoding</em>, <em>errors</em>, <em>newline</em> and <em>closefd</em>. Also note that an
  591. invalid <em>mode</em> argument now raises <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>, not
  592. <a class="reference internal" href="../library/exceptions.html#IOError" title="IOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IOError</span></code></a>. The binary file object underlying a text file
  593. object can be accessed as <code class="xref py py-attr docutils literal notranslate"><span class="pre">f.buffer</span></code> (but beware that the
  594. text object maintains a buffer of itself in order to speed up
  595. the encoding and decoding operations).</p></li>
  596. <li><p><a class="reference internal" href="2.6.html#pep-3118"><span class="std std-ref">PEP 3118: Revised Buffer Protocol</span></a>. The old builtin <code class="xref py py-func docutils literal notranslate"><span class="pre">buffer()</span></code> is now really gone;
  597. the new builtin <a class="reference internal" href="../library/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-func docutils literal notranslate"><span class="pre">memoryview()</span></code></a> provides (mostly) similar
  598. functionality.</p></li>
  599. <li><p><a class="reference internal" href="2.6.html#pep-3119"><span class="std std-ref">PEP 3119: Abstract Base Classes</span></a>. 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 and the ABCs defined in the
  600. <a class="reference internal" href="../library/collections.html#module-collections" title="collections: Container datatypes"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code></a> module plays a somewhat more prominent role in
  601. the language now, and built-in collection 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>
  602. and <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> conform to the <code class="xref py py-class docutils literal notranslate"><span class="pre">collections.MutableMapping</span></code>
  603. and <code class="xref py py-class docutils literal notranslate"><span class="pre">collections.MutableSequence</span></code> ABCs, respectively.</p></li>
  604. <li><p><a class="reference internal" href="2.6.html#pep-3127"><span class="std std-ref">PEP 3127: Integer Literal Support and Syntax</span></a>. As mentioned above, the new octal literal
  605. notation is the only one supported, and binary literals have been
  606. added.</p></li>
  607. <li><p><a class="reference internal" href="2.6.html#pep-3129"><span class="std std-ref">PEP 3129: Class Decorators</span></a>.</p></li>
  608. <li><p><a class="reference internal" href="2.6.html#pep-3141"><span class="std std-ref">PEP 3141: A Type Hierarchy for Numbers</span></a>. The <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 is another new use of
  609. ABCs, defining Python’s “numeric tower”. Also note the new
  610. <a class="reference internal" href="../library/fractions.html#module-fractions" title="fractions: Rational numbers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">fractions</span></code></a> module which implements <a class="reference internal" href="../library/numbers.html#numbers.Rational" title="numbers.Rational"><code class="xref py py-class docutils literal notranslate"><span class="pre">numbers.Rational</span></code></a>.</p></li>
  611. </ul>
  612. </section>
  613. <section id="library-changes">
  614. <h2>Library Changes<a class="headerlink" href="#library-changes" title="Permalink to this headline">¶</a></h2>
  615. <p>Due to time constraints, this document does not exhaustively cover the
  616. very extensive changes to the standard library. <span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-3108/"><strong>PEP 3108</strong></a> is the
  617. reference for the major changes to the library. Here’s a capsule
  618. review:</p>
  619. <ul>
  620. <li><p>Many old modules were removed. Some, like <code class="xref py py-mod docutils literal notranslate"><span class="pre">gopherlib</span></code> (no
  621. longer used) and <code class="xref py py-mod docutils literal notranslate"><span class="pre">md5</span></code> (replaced by <a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a>), were
  622. already deprecated by <span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-0004/"><strong>PEP 4</strong></a>. Others were removed as a result
  623. of the removal of support for various platforms such as Irix, BeOS
  624. and Mac OS 9 (see <span class="target" id="index-19"></span><a class="pep reference external" href="https://peps.python.org/pep-0011/"><strong>PEP 11</strong></a>). Some modules were also selected for
  625. removal in Python 3.0 due to lack of use or because a better
  626. replacement exists. See <span class="target" id="index-20"></span><a class="pep reference external" href="https://peps.python.org/pep-3108/"><strong>PEP 3108</strong></a> for an exhaustive list.</p></li>
  627. <li><p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">bsddb3</span></code> package was removed because its presence in the
  628. core standard library has proved over time to be a particular burden
  629. for the core developers due to testing instability and Berkeley DB’s
  630. release schedule. However, the package is alive and well,
  631. externally maintained at <a class="reference external" href="https://www.jcea.es/programacion/pybsddb.htm">https://www.jcea.es/programacion/pybsddb.htm</a>.</p></li>
  632. <li><p>Some modules were renamed because their old name disobeyed
  633. <span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a>, or for various other reasons. Here’s the list:</p>
  634. <table class="docutils align-default">
  635. <colgroup>
  636. <col style="width: 50%" />
  637. <col style="width: 50%" />
  638. </colgroup>
  639. <thead>
  640. <tr class="row-odd"><th class="head"><p>Old Name</p></th>
  641. <th class="head"><p>New Name</p></th>
  642. </tr>
  643. </thead>
  644. <tbody>
  645. <tr class="row-even"><td><p>_winreg</p></td>
  646. <td><p>winreg</p></td>
  647. </tr>
  648. <tr class="row-odd"><td><p>ConfigParser</p></td>
  649. <td><p>configparser</p></td>
  650. </tr>
  651. <tr class="row-even"><td><p>copy_reg</p></td>
  652. <td><p>copyreg</p></td>
  653. </tr>
  654. <tr class="row-odd"><td><p>Queue</p></td>
  655. <td><p>queue</p></td>
  656. </tr>
  657. <tr class="row-even"><td><p>SocketServer</p></td>
  658. <td><p>socketserver</p></td>
  659. </tr>
  660. <tr class="row-odd"><td><p>markupbase</p></td>
  661. <td><p>_markupbase</p></td>
  662. </tr>
  663. <tr class="row-even"><td><p>repr</p></td>
  664. <td><p>reprlib</p></td>
  665. </tr>
  666. <tr class="row-odd"><td><p>test.test_support</p></td>
  667. <td><p>test.support</p></td>
  668. </tr>
  669. </tbody>
  670. </table>
  671. </li>
  672. <li><p>A common pattern in Python 2.x is to have one version of a module
  673. implemented in pure Python, with an optional accelerated version
  674. implemented as a C extension; for example, <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a> and
  675. <code class="xref py py-mod docutils literal notranslate"><span class="pre">cPickle</span></code>. This places the burden of importing the accelerated
  676. version and falling back on the pure Python version on each user of
  677. these modules. In Python 3.0, the accelerated versions are
  678. considered implementation details of the pure Python versions.
  679. Users should always import the standard version, which attempts to
  680. import the accelerated version and falls back to the pure Python
  681. version. The <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a> / <code class="xref py py-mod docutils literal notranslate"><span class="pre">cPickle</span></code> pair received this
  682. treatment. The <a class="reference internal" href="../library/profile.html#module-profile" title="profile: Python source profiler."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code></a> module is on the list for 3.1. The
  683. <code class="xref py py-mod docutils literal notranslate"><span class="pre">StringIO</span></code> module has been turned into a class 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>
  684. module.</p></li>
  685. <li><p>Some related modules have been grouped into packages, and usually
  686. the submodule names have been simplified. The resulting new
  687. packages are:</p>
  688. <ul class="simple">
  689. <li><p><a class="reference internal" href="../library/dbm.html#module-dbm" title="dbm: Interfaces to various Unix &quot;database&quot; formats."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm</span></code></a> (<code class="xref py py-mod docutils literal notranslate"><span class="pre">anydbm</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">dbhash</span></code>, <a class="reference internal" href="../library/dbm.html#module-dbm" title="dbm: Interfaces to various Unix &quot;database&quot; formats."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm</span></code></a>,
  690. <code class="xref py py-mod docutils literal notranslate"><span class="pre">dumbdbm</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">gdbm</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">whichdb</span></code>).</p></li>
  691. <li><p><a class="reference internal" href="../library/html.html#module-html" title="html: Helpers for manipulating HTML."><code class="xref py py-mod docutils literal notranslate"><span class="pre">html</span></code></a> (<code class="xref py py-mod docutils literal notranslate"><span class="pre">HTMLParser</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">htmlentitydefs</span></code>).</p></li>
  692. <li><p><a class="reference internal" href="../library/http.html#module-http" title="http: HTTP status codes and messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">http</span></code></a> (<code class="xref py py-mod docutils literal notranslate"><span class="pre">httplib</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">BaseHTTPServer</span></code>,
  693. <code class="xref py py-mod docutils literal notranslate"><span class="pre">CGIHTTPServer</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">SimpleHTTPServer</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">Cookie</span></code>,
  694. <code class="xref py py-mod docutils literal notranslate"><span class="pre">cookielib</span></code>).</p></li>
  695. <li><p><a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a> (all <code class="xref py py-mod docutils literal notranslate"><span class="pre">Tkinter</span></code>-related modules except
  696. <a class="reference internal" href="../library/turtle.html#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a>). The target audience of <a class="reference internal" href="../library/turtle.html#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> doesn’t
  697. really care about <a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a>. Also note that as of Python
  698. 2.6, the functionality of <a class="reference internal" href="../library/turtle.html#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> has been greatly enhanced.</p></li>
  699. <li><p><a class="reference internal" href="../library/urllib.html#module-urllib" title="urllib"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib</span></code></a> (<a class="reference internal" href="../library/urllib.html#module-urllib" title="urllib"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib</span></code></a>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib2</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">urlparse</span></code>,
  700. <code class="xref py py-mod docutils literal notranslate"><span class="pre">robotparse</span></code>).</p></li>
  701. <li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">xmlrpc</span></code> (<code class="xref py py-mod docutils literal notranslate"><span class="pre">xmlrpclib</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">DocXMLRPCServer</span></code>,
  702. <code class="xref py py-mod docutils literal notranslate"><span class="pre">SimpleXMLRPCServer</span></code>).</p></li>
  703. </ul>
  704. </li>
  705. </ul>
  706. <p>Some other changes to standard library modules, not covered by
  707. <span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-3108/"><strong>PEP 3108</strong></a>:</p>
  708. <ul class="simple">
  709. <li><p>Killed <code class="xref py py-mod docutils literal notranslate"><span class="pre">sets</span></code>. Use the built-in <a class="reference internal" href="../library/stdtypes.html#set" title="set"><code class="xref py py-func docutils literal notranslate"><span class="pre">set()</span></code></a> class.</p></li>
  710. <li><p>Cleanup of the <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module: removed <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exitfunc()</span></code>,
  711. <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_clear()</span></code>, <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_type</span></code>, <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_value</span></code>,
  712. <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_traceback</span></code>. (Note that <a class="reference internal" href="../library/sys.html#sys.last_type" title="sys.last_type"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.last_type</span></code></a>
  713. etc. remain.)</p></li>
  714. <li><p>Cleanup of the <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> type: the <code class="xref py py-meth docutils literal notranslate"><span class="pre">read()</span></code> and
  715. <code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code> methods are gone; use <code class="xref py py-meth docutils literal notranslate"><span class="pre">fromfile()</span></code> and
  716. <code class="xref py py-meth docutils literal notranslate"><span class="pre">tofile()</span></code> instead. Also, the <code class="docutils literal notranslate"><span class="pre">'c'</span></code> typecode for array is
  717. gone – use either <code class="docutils literal notranslate"><span class="pre">'b'</span></code> for bytes or <code class="docutils literal notranslate"><span class="pre">'u'</span></code> for Unicode
  718. characters.</p></li>
  719. <li><p>Cleanup of the <a class="reference internal" href="../library/operator.html#module-operator" title="operator: Functions corresponding to the standard operators."><code class="xref py py-mod docutils literal notranslate"><span class="pre">operator</span></code></a> module: removed
  720. <code class="xref py py-func docutils literal notranslate"><span class="pre">sequenceIncludes()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">isCallable()</span></code>.</p></li>
  721. <li><p>Cleanup of the <code class="xref py py-mod docutils literal notranslate"><span class="pre">thread</span></code> module: <code class="xref py py-func docutils literal notranslate"><span class="pre">acquire_lock()</span></code> and
  722. <code class="xref py py-func docutils literal notranslate"><span class="pre">release_lock()</span></code> are gone; use <code class="xref py py-func docutils literal notranslate"><span class="pre">acquire()</span></code> and
  723. <code class="xref py py-func docutils literal notranslate"><span class="pre">release()</span></code> instead.</p></li>
  724. <li><p>Cleanup of 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> module: removed the <code class="xref py py-func docutils literal notranslate"><span class="pre">jumpahead()</span></code> API.</p></li>
  725. <li><p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">new</span></code> module is gone.</p></li>
  726. <li><p>The functions <code class="xref py py-func docutils literal notranslate"><span class="pre">os.tmpnam()</span></code>, <code class="xref py py-func docutils literal notranslate"><span class="pre">os.tempnam()</span></code> and
  727. <code class="xref py py-func docutils literal notranslate"><span class="pre">os.tmpfile()</span></code> have been removed in favor of the <a class="reference internal" href="../library/tempfile.html#module-tempfile" title="tempfile: Generate temporary files and directories."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tempfile</span></code></a>
  728. module.</p></li>
  729. <li><p>The <a class="reference internal" href="../library/tokenize.html#module-tokenize" title="tokenize: Lexical scanner for Python source code."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tokenize</span></code></a> module has been changed to work with bytes. The
  730. main entry point is now <a class="reference internal" href="../library/tokenize.html#tokenize.tokenize" title="tokenize.tokenize"><code class="xref py py-func docutils literal notranslate"><span class="pre">tokenize.tokenize()</span></code></a>, instead of
  731. generate_tokens.</p></li>
  732. <li><p><code class="xref py py-data docutils literal notranslate"><span class="pre">string.letters</span></code> and its friends (<code class="xref py py-data docutils literal notranslate"><span class="pre">string.lowercase</span></code> and
  733. <code class="xref py py-data docutils literal notranslate"><span class="pre">string.uppercase</span></code>) are gone. Use
  734. <a class="reference internal" href="../library/string.html#string.ascii_letters" title="string.ascii_letters"><code class="xref py py-data docutils literal notranslate"><span class="pre">string.ascii_letters</span></code></a> etc. instead. (The reason for the
  735. removal is that <code class="xref py py-data docutils literal notranslate"><span class="pre">string.letters</span></code> and friends had
  736. locale-specific behavior, which is a bad idea for such
  737. attractively named global “constants”.)</p></li>
  738. <li><p>Renamed module <code class="xref py py-mod docutils literal notranslate"><span class="pre">__builtin__</span></code> to <a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a> (removing the
  739. underscores, adding an ‘s’). The <code class="xref py py-data docutils literal notranslate"><span class="pre">__builtins__</span></code> variable
  740. found in most global namespaces is unchanged. To modify a builtin,
  741. you should use <a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a>, not <code class="xref py py-data docutils literal notranslate"><span class="pre">__builtins__</span></code>!</p></li>
  742. </ul>
  743. </section>
  744. <section id="pep-3101-a-new-approach-to-string-formatting">
  745. <h2><span class="target" id="index-23"></span><a class="pep reference external" href="https://peps.python.org/pep-3101/"><strong>PEP 3101</strong></a>: A New Approach To String Formatting<a class="headerlink" href="#pep-3101-a-new-approach-to-string-formatting" title="Permalink to this headline">¶</a></h2>
  746. <ul class="simple">
  747. <li><p>A new system for built-in string formatting operations replaces the
  748. <code class="docutils literal notranslate"><span class="pre">%</span></code> string formatting operator. (However, the <code class="docutils literal notranslate"><span class="pre">%</span></code> operator is
  749. still supported; it will be deprecated in Python 3.1 and removed
  750. from the language at some later time.) Read <span class="target" id="index-24"></span><a class="pep reference external" href="https://peps.python.org/pep-3101/"><strong>PEP 3101</strong></a> for the full
  751. scoop.</p></li>
  752. </ul>
  753. </section>
  754. <section id="changes-to-exceptions">
  755. <h2>Changes To Exceptions<a class="headerlink" href="#changes-to-exceptions" title="Permalink to this headline">¶</a></h2>
  756. <p>The APIs for raising and catching exception have been cleaned up and
  757. new powerful features added:</p>
  758. <ul>
  759. <li><p><span class="target" id="index-25"></span><a class="pep reference external" href="https://peps.python.org/pep-0352/"><strong>PEP 352</strong></a>: All exceptions must be derived (directly or indirectly)
  760. from <a class="reference internal" href="../library/exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a>. This is the root of the exception
  761. hierarchy. This is not new as a recommendation, but the
  762. <em>requirement</em> to inherit from <a class="reference internal" href="../library/exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> is new. (Python
  763. 2.6 still allowed classic classes to be raised, and placed no
  764. restriction on what you can catch.) As a consequence, string
  765. exceptions are finally truly and utterly dead.</p></li>
  766. <li><p>Almost all exceptions should actually derive from <a class="reference internal" href="../library/exceptions.html#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>;
  767. <a class="reference internal" href="../library/exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> should only be used as a base class for
  768. exceptions that should only be handled at the top level, such as
  769. <a class="reference internal" href="../library/exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> or <a class="reference internal" href="../library/exceptions.html#KeyboardInterrupt" title="KeyboardInterrupt"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyboardInterrupt</span></code></a>. The recommended
  770. idiom for handling all exceptions except for this latter category is
  771. to use <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> <a class="reference internal" href="../library/exceptions.html#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>.</p></li>
  772. <li><p><code class="xref py py-exc docutils literal notranslate"><span class="pre">StandardError</span></code> was removed.</p></li>
  773. <li><p>Exceptions no longer behave as sequences. Use the <code class="xref py py-attr docutils literal notranslate"><span class="pre">args</span></code>
  774. attribute instead.</p></li>
  775. <li><p><span class="target" id="index-26"></span><a class="pep reference external" href="https://peps.python.org/pep-3109/"><strong>PEP 3109</strong></a>: Raising exceptions. You must now use <code class="samp docutils literal notranslate"><span class="pre">raise</span>
  776. <em><span class="pre">Exception</span></em><span class="pre">(</span><em><span class="pre">args</span></em><span class="pre">)</span></code> instead of <code class="samp docutils literal notranslate"><span class="pre">raise</span> <em><span class="pre">Exception</span></em><span class="pre">,</span> <em><span class="pre">args</span></em></code>.
  777. Additionally, you can no longer explicitly specify a traceback;
  778. instead, if you <em>have</em> to do this, you can assign directly to the
  779. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__traceback__</span></code> attribute (see below).</p></li>
  780. <li><p><span class="target" id="index-27"></span><a class="pep reference external" href="https://peps.python.org/pep-3110/"><strong>PEP 3110</strong></a>: Catching exceptions. You must now use
  781. <code class="samp docutils literal notranslate"><span class="pre">except</span> <em><span class="pre">SomeException</span></em> <span class="pre">as</span> <em><span class="pre">variable</span></em></code> instead
  782. of <code class="samp docutils literal notranslate"><span class="pre">except</span> <em><span class="pre">SomeException</span></em><span class="pre">,</span> <em><span class="pre">variable</span></em></code>. Moreover, the
  783. <em>variable</em> is explicitly deleted when the <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> block
  784. is left.</p></li>
  785. <li><p><span class="target" id="index-28"></span><a class="pep reference external" href="https://peps.python.org/pep-3134/"><strong>PEP 3134</strong></a>: Exception chaining. There are two cases: implicit
  786. chaining and explicit chaining. Implicit chaining happens when an
  787. exception is raised in an <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> or <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a>
  788. handler block. This usually happens due to a bug in the handler
  789. block; we call this a <em>secondary</em> exception. In this case, the
  790. original exception (that was being handled) is saved as the
  791. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__context__</span></code> attribute of the secondary exception.
  792. Explicit chaining is invoked with this syntax:</p>
  793. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">raise</span> <span class="n">SecondaryException</span><span class="p">()</span> <span class="kn">from</span> <span class="nn">primary_exception</span>
  794. </pre></div>
  795. </div>
  796. <p>(where <em>primary_exception</em> is any expression that produces an
  797. exception object, probably an exception that was previously caught).
  798. In this case, the primary exception is stored on the
  799. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> attribute of the secondary exception. The
  800. traceback printed when an unhandled exception occurs walks the chain
  801. of <code class="xref py py-attr docutils literal notranslate"><span class="pre">__cause__</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">__context__</span></code> attributes and prints a
  802. separate traceback for each component of the chain, with the primary
  803. exception at the top. (Java users may recognize this behavior.)</p>
  804. </li>
  805. <li><p><span class="target" id="index-29"></span><a class="pep reference external" href="https://peps.python.org/pep-3134/"><strong>PEP 3134</strong></a>: Exception objects now store their traceback as the
  806. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__traceback__</span></code> attribute. This means that an exception
  807. object now contains all the information pertaining to an exception,
  808. and there are fewer reasons to use <a class="reference internal" href="../library/sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_info()</span></code></a> (though the
  809. latter is not removed).</p></li>
  810. <li><p>A few exception messages are improved when Windows fails to load an
  811. extension module. For example, <code class="docutils literal notranslate"><span class="pre">error</span> <span class="pre">code</span> <span class="pre">193</span></code> is now <code class="docutils literal notranslate"><span class="pre">%1</span> <span class="pre">is</span>
  812. <span class="pre">not</span> <span class="pre">a</span> <span class="pre">valid</span> <span class="pre">Win32</span> <span class="pre">application</span></code>. Strings now deal with non-English
  813. locales.</p></li>
  814. </ul>
  815. </section>
  816. <section id="miscellaneous-other-changes">
  817. <h2>Miscellaneous Other Changes<a class="headerlink" href="#miscellaneous-other-changes" title="Permalink to this headline">¶</a></h2>
  818. <section id="operators-and-special-methods">
  819. <h3>Operators And Special Methods<a class="headerlink" href="#operators-and-special-methods" title="Permalink to this headline">¶</a></h3>
  820. <ul class="simple">
  821. <li><p><code class="docutils literal notranslate"><span class="pre">!=</span></code> now returns the opposite of <code class="docutils literal notranslate"><span class="pre">==</span></code>, unless <code class="docutils literal notranslate"><span class="pre">==</span></code> returns
  822. <a class="reference internal" href="../library/constants.html#NotImplemented" title="NotImplemented"><code class="xref py py-data docutils literal notranslate"><span class="pre">NotImplemented</span></code></a>.</p></li>
  823. <li><p>The concept of “unbound methods” has been removed from the language.
  824. When referencing a method as a class attribute, you now get a plain
  825. function object.</p></li>
  826. <li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getslice__()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">__setslice__()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">__delslice__()</span></code>
  827. were killed. The syntax <code class="docutils literal notranslate"><span class="pre">a[i:j]</span></code> now translates to
  828. <code class="docutils literal notranslate"><span class="pre">a.__getitem__(slice(i,</span> <span class="pre">j))</span></code> (or <code class="xref py py-meth docutils literal notranslate"><span class="pre">__setitem__()</span></code> or
  829. <code class="xref py py-meth docutils literal notranslate"><span class="pre">__delitem__()</span></code>, when used as an assignment or deletion target,
  830. respectively).</p></li>
  831. <li><p><span class="target" id="index-30"></span><a class="pep reference external" href="https://peps.python.org/pep-3114/"><strong>PEP 3114</strong></a>: the standard <a class="reference internal" href="../library/functions.html#next" title="next"><code class="xref py py-meth docutils literal notranslate"><span class="pre">next()</span></code></a> method has been renamed to
  832. <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>.</p></li>
  833. <li><p>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">__oct__()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">__hex__()</span></code> special methods are removed
  834. – <a class="reference internal" href="../library/functions.html#oct" title="oct"><code class="xref py py-func docutils literal notranslate"><span class="pre">oct()</span></code></a> and <a class="reference internal" href="../library/functions.html#hex" title="hex"><code class="xref py py-func docutils literal notranslate"><span class="pre">hex()</span></code></a> use <code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code> now to convert
  835. the argument to an integer.</p></li>
  836. <li><p>Removed support for <code class="xref py py-attr docutils literal notranslate"><span class="pre">__members__</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">__methods__</span></code>.</p></li>
  837. <li><p>The function attributes named <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_X</span></code> have been renamed to
  838. use the <code class="xref py py-data docutils literal notranslate"><span class="pre">__X__</span></code> form, freeing up these names in the function
  839. attribute namespace for user-defined attributes. To wit,
  840. <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_closure</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_code</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_defaults</span></code>,
  841. <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_dict</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_doc</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_globals</span></code>,
  842. <code class="xref py py-attr docutils literal notranslate"><span class="pre">func_name</span></code> were renamed to <code class="xref py py-attr docutils literal notranslate"><span class="pre">__closure__</span></code>,
  843. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__code__</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">__defaults__</span></code>, <a class="reference internal" href="../library/stdtypes.html#object.__dict__" title="object.__dict__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__dict__</span></code></a>,
  844. <code class="xref py py-attr docutils literal notranslate"><span class="pre">__doc__</span></code>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">__globals__</span></code>, <a class="reference internal" href="../library/stdtypes.html#definition.__name__" title="definition.__name__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__name__</span></code></a>,
  845. respectively.</p></li>
  846. <li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">__nonzero__()</span></code> is now <a class="reference internal" href="../reference/datamodel.html#object.__bool__" title="object.__bool__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__bool__()</span></code></a>.</p></li>
  847. </ul>
  848. </section>
  849. <section id="builtins">
  850. <h3>Builtins<a class="headerlink" href="#builtins" title="Permalink to this headline">¶</a></h3>
  851. <ul class="simple">
  852. <li><p><span class="target" id="index-31"></span><a class="pep reference external" href="https://peps.python.org/pep-3135/"><strong>PEP 3135</strong></a>: New <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a>. You can now invoke <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a>
  853. without arguments and (assuming this is in a regular instance method
  854. defined inside a <a class="reference internal" href="../reference/compound_stmts.html#class"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">class</span></code></a> statement) the right class and
  855. instance will automatically be chosen. With arguments, the behavior
  856. of <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a> is unchanged.</p></li>
  857. <li><p><span class="target" id="index-32"></span><a class="pep reference external" href="https://peps.python.org/pep-3111/"><strong>PEP 3111</strong></a>: <code class="xref py py-func docutils literal notranslate"><span class="pre">raw_input()</span></code> was renamed to <a class="reference internal" href="../library/functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a>. That
  858. is, the new <a class="reference internal" href="../library/functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a> function reads a line from
  859. <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> and returns it with the trailing newline stripped.
  860. It raises <a class="reference internal" href="../library/exceptions.html#EOFError" title="EOFError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EOFError</span></code></a> if the input is terminated prematurely.
  861. To get the old behavior of <a class="reference internal" href="../library/functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a>, use <code class="docutils literal notranslate"><span class="pre">eval(input())</span></code>.</p></li>
  862. <li><p>A new built-in function <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> was added to call the
  863. <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 on an object.</p></li>
  864. <li><p>The <a class="reference internal" href="../library/functions.html#round" title="round"><code class="xref py py-func docutils literal notranslate"><span class="pre">round()</span></code></a> function rounding strategy and return type have
  865. changed. Exact halfway cases are now rounded to the nearest even
  866. result instead of away from zero. (For example, <code class="docutils literal notranslate"><span class="pre">round(2.5)</span></code> now
  867. returns <code class="docutils literal notranslate"><span class="pre">2</span></code> rather than <code class="docutils literal notranslate"><span class="pre">3</span></code>.) <code class="docutils literal notranslate"><span class="pre">round(x[,</span> <span class="pre">n])</span></code> now
  868. delegates to <code class="docutils literal notranslate"><span class="pre">x.__round__([n])</span></code> instead of always returning a
  869. float. It generally returns an integer when called with a single
  870. argument and a value of the same type as <code class="docutils literal notranslate"><span class="pre">x</span></code> when called with two
  871. arguments.</p></li>
  872. <li><p>Moved <code class="xref py py-func docutils literal notranslate"><span class="pre">intern()</span></code> to <a class="reference internal" href="../library/sys.html#sys.intern" title="sys.intern"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.intern()</span></code></a>.</p></li>
  873. <li><p>Removed: <code class="xref py py-func docutils literal notranslate"><span class="pre">apply()</span></code>. Instead of <code class="docutils literal notranslate"><span class="pre">apply(f,</span> <span class="pre">args)</span></code> use
  874. <code class="docutils literal notranslate"><span class="pre">f(*args)</span></code>.</p></li>
  875. <li><p>Removed <a class="reference internal" href="../library/functions.html#callable" title="callable"><code class="xref py py-func docutils literal notranslate"><span class="pre">callable()</span></code></a>. Instead of <code class="docutils literal notranslate"><span class="pre">callable(f)</span></code> you can use
  876. <code class="docutils literal notranslate"><span class="pre">isinstance(f,</span> <span class="pre">collections.Callable)</span></code>. The <code class="xref py py-func docutils literal notranslate"><span class="pre">operator.isCallable()</span></code>
  877. function is also gone.</p></li>
  878. <li><p>Removed <code class="xref py py-func docutils literal notranslate"><span class="pre">coerce()</span></code>. This function no longer serves a purpose
  879. now that classic classes are gone.</p></li>
  880. <li><p>Removed <code class="xref py py-func docutils literal notranslate"><span class="pre">execfile()</span></code>. Instead of <code class="docutils literal notranslate"><span class="pre">execfile(fn)</span></code> use
  881. <code class="docutils literal notranslate"><span class="pre">exec(open(fn).read())</span></code>.</p></li>
  882. <li><p>Removed the <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code> type. Use <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>. There are now several
  883. different kinds of streams that open can return 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.</p></li>
  884. <li><p>Removed <code class="xref py py-func docutils literal notranslate"><span class="pre">reduce()</span></code>. Use <a class="reference internal" href="../library/functools.html#functools.reduce" title="functools.reduce"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.reduce()</span></code></a> if you really
  885. need it; however, 99 percent of the time an explicit <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>
  886. loop is more readable.</p></li>
  887. <li><p>Removed <code class="xref py py-func docutils literal notranslate"><span class="pre">reload()</span></code>. Use <code class="xref py py-func docutils literal notranslate"><span class="pre">imp.reload()</span></code>.</p></li>
  888. <li><p>Removed. <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.has_key()</span></code> – use the <a class="reference internal" href="../reference/expressions.html#in"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">in</span></code></a> operator
  889. instead.</p></li>
  890. </ul>
  891. </section>
  892. </section>
  893. <section id="build-and-c-api-changes">
  894. <h2>Build and C API Changes<a class="headerlink" href="#build-and-c-api-changes" title="Permalink to this headline">¶</a></h2>
  895. <p>Due to time constraints, here is a <em>very</em> incomplete list of changes
  896. to the C API.</p>
  897. <ul class="simple">
  898. <li><p>Support for several platforms was dropped, including but not limited
  899. to Mac OS 9, BeOS, RISCOS, Irix, and Tru64.</p></li>
  900. <li><p><span class="target" id="index-33"></span><a class="pep reference external" href="https://peps.python.org/pep-3118/"><strong>PEP 3118</strong></a>: New Buffer API.</p></li>
  901. <li><p><span class="target" id="index-34"></span><a class="pep reference external" href="https://peps.python.org/pep-3121/"><strong>PEP 3121</strong></a>: Extension Module Initialization &amp; Finalization.</p></li>
  902. <li><p><span class="target" id="index-35"></span><a class="pep reference external" href="https://peps.python.org/pep-3123/"><strong>PEP 3123</strong></a>: Making <a class="reference internal" href="../c-api/structures.html#c.PyObject_HEAD" title="PyObject_HEAD"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PyObject_HEAD</span></code></a> conform to standard C.</p></li>
  903. <li><p>No more C API support for restricted execution.</p></li>
  904. <li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyNumber_Coerce()</span></code>, <code class="xref c c-func docutils literal notranslate"><span class="pre">PyNumber_CoerceEx()</span></code>,
  905. <code class="xref c c-func docutils literal notranslate"><span class="pre">PyMember_Get()</span></code>, and <code class="xref c c-func docutils literal notranslate"><span class="pre">PyMember_Set()</span></code> C APIs are removed.</p></li>
  906. <li><p>New C API <a class="reference internal" href="../c-api/import.html#c.PyImport_ImportModuleNoBlock" title="PyImport_ImportModuleNoBlock"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModuleNoBlock()</span></code></a>, works like
  907. <a class="reference internal" href="../c-api/import.html#c.PyImport_ImportModule" title="PyImport_ImportModule"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModule()</span></code></a> but won’t block on the import lock
  908. (returning an error instead).</p></li>
  909. <li><p>Renamed the boolean conversion C-level slot and method:
  910. <code class="docutils literal notranslate"><span class="pre">nb_nonzero</span></code> is now <code class="docutils literal notranslate"><span class="pre">nb_bool</span></code>.</p></li>
  911. <li><p>Removed <code class="xref c c-macro docutils literal notranslate"><span class="pre">METH_OLDARGS</span></code> and <code class="xref c c-macro docutils literal notranslate"><span class="pre">WITH_CYCLE_GC</span></code> from the C API.</p></li>
  912. </ul>
  913. </section>
  914. <section id="performance">
  915. <h2>Performance<a class="headerlink" href="#performance" title="Permalink to this headline">¶</a></h2>
  916. <p>The net result of the 3.0 generalizations is that Python 3.0 runs the
  917. pystone benchmark around 10% slower than Python 2.5. Most likely the
  918. biggest cause is the removal of special-casing for small integers.
  919. There’s room for improvement, but it will happen after 3.0 is
  920. released!</p>
  921. </section>
  922. <section id="porting-to-python-3-0">
  923. <h2>Porting To Python 3.0<a class="headerlink" href="#porting-to-python-3-0" title="Permalink to this headline">¶</a></h2>
  924. <p>For porting existing Python 2.5 or 2.6 source code to Python 3.0, the
  925. best strategy is the following:</p>
  926. <ol class="arabic simple" start="0">
  927. <li><p>(Prerequisite:) Start with excellent test coverage.</p></li>
  928. <li><p>Port to Python 2.6. This should be no more work than the average
  929. port from Python 2.x to Python 2.(x+1). Make sure all your tests
  930. pass.</p></li>
  931. <li><p>(Still using 2.6:) Turn on the <code class="xref std std-option docutils literal notranslate"><span class="pre">-3</span></code> command line switch.
  932. This enables warnings about features that will be removed (or
  933. change) in 3.0. Run your test suite again, and fix code that you
  934. get warnings about until there are no warnings left, and all your
  935. tests still pass.</p></li>
  936. <li><p>Run the <code class="docutils literal notranslate"><span class="pre">2to3</span></code> source-to-source translator over your source code
  937. tree. (See <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> for more on this tool.) Run the
  938. result of the translation under Python 3.0. Manually fix up any
  939. remaining issues, fixing problems until all tests pass again.</p></li>
  940. </ol>
  941. <p>It is not recommended to try to write source code that runs unchanged
  942. under both Python 2.6 and 3.0; you’d have to use a very contorted
  943. coding style, e.g. avoiding <code class="docutils literal notranslate"><span class="pre">print</span></code> statements, metaclasses,
  944. and much more. If you are maintaining a library that needs to support
  945. both Python 2.6 and Python 3.0, the best approach is to modify step 3
  946. above by editing the 2.6 version of the source code and running the
  947. <code class="docutils literal notranslate"><span class="pre">2to3</span></code> translator again, rather than editing the 3.0 version of the
  948. source code.</p>
  949. <p>For porting C extensions to Python 3.0, please see <a class="reference internal" href="../howto/cporting.html#cporting-howto"><span class="std std-ref">Porting Extension Modules to Python 3</span></a>.</p>
  950. </section>
  951. </section>
  952. <div class="clearer"></div>
  953. </div>
  954. </div>
  955. </div>
  956. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  957. <div class="sphinxsidebarwrapper">
  958. <div>
  959. <h3><a href="../contents.html">Table of Contents</a></h3>
  960. <ul>
  961. <li><a class="reference internal" href="#">What’s New In Python 3.0</a><ul>
  962. <li><a class="reference internal" href="#common-stumbling-blocks">Common Stumbling Blocks</a><ul>
  963. <li><a class="reference internal" href="#print-is-a-function">Print Is A Function</a></li>
  964. <li><a class="reference internal" href="#views-and-iterators-instead-of-lists">Views And Iterators Instead Of Lists</a></li>
  965. <li><a class="reference internal" href="#ordering-comparisons">Ordering Comparisons</a></li>
  966. <li><a class="reference internal" href="#integers">Integers</a></li>
  967. <li><a class="reference internal" href="#text-vs-data-instead-of-unicode-vs-8-bit">Text Vs. Data Instead Of Unicode Vs. 8-bit</a></li>
  968. </ul>
  969. </li>
  970. <li><a class="reference internal" href="#overview-of-syntax-changes">Overview Of Syntax Changes</a><ul>
  971. <li><a class="reference internal" href="#new-syntax">New Syntax</a></li>
  972. <li><a class="reference internal" href="#changed-syntax">Changed Syntax</a></li>
  973. <li><a class="reference internal" href="#removed-syntax">Removed Syntax</a></li>
  974. </ul>
  975. </li>
  976. <li><a class="reference internal" href="#changes-already-present-in-python-2-6">Changes Already Present In Python 2.6</a></li>
  977. <li><a class="reference internal" href="#library-changes">Library Changes</a></li>
  978. <li><a class="reference internal" href="#pep-3101-a-new-approach-to-string-formatting"><strong>PEP 3101</strong>: A New Approach To String Formatting</a></li>
  979. <li><a class="reference internal" href="#changes-to-exceptions">Changes To Exceptions</a></li>
  980. <li><a class="reference internal" href="#miscellaneous-other-changes">Miscellaneous Other Changes</a><ul>
  981. <li><a class="reference internal" href="#operators-and-special-methods">Operators And Special Methods</a></li>
  982. <li><a class="reference internal" href="#builtins">Builtins</a></li>
  983. </ul>
  984. </li>
  985. <li><a class="reference internal" href="#build-and-c-api-changes">Build and C API Changes</a></li>
  986. <li><a class="reference internal" href="#performance">Performance</a></li>
  987. <li><a class="reference internal" href="#porting-to-python-3-0">Porting To Python 3.0</a></li>
  988. </ul>
  989. </li>
  990. </ul>
  991. </div>
  992. <div>
  993. <h4>Previous topic</h4>
  994. <p class="topless"><a href="3.1.html"
  995. title="previous chapter">What’s New In Python 3.1</a></p>
  996. </div>
  997. <div>
  998. <h4>Next topic</h4>
  999. <p class="topless"><a href="2.7.html"
  1000. title="next chapter">What’s New in Python 2.7</a></p>
  1001. </div>
  1002. <div role="note" aria-label="source link">
  1003. <h3>This Page</h3>
  1004. <ul class="this-page-menu">
  1005. <li><a href="../bugs.html">Report a Bug</a></li>
  1006. <li>
  1007. <a href="https://github.com/python/cpython/blob/main/Doc/whatsnew/3.0.rst"
  1008. rel="nofollow">Show Source
  1009. </a>
  1010. </li>
  1011. </ul>
  1012. </div>
  1013. </div>
  1014. </div>
  1015. <div class="clearer"></div>
  1016. </div>
  1017. <div class="related" role="navigation" aria-label="related navigation">
  1018. <h3>Navigation</h3>
  1019. <ul>
  1020. <li class="right" style="margin-right: 10px">
  1021. <a href="../genindex.html" title="General Index"
  1022. >index</a></li>
  1023. <li class="right" >
  1024. <a href="../py-modindex.html" title="Python Module Index"
  1025. >modules</a> |</li>
  1026. <li class="right" >
  1027. <a href="2.7.html" title="What’s New in Python 2.7"
  1028. >next</a> |</li>
  1029. <li class="right" >
  1030. <a href="3.1.html" title="What’s New In Python 3.1"
  1031. >previous</a> |</li>
  1032. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  1033. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  1034. <li class="switchers">
  1035. <div class="language_switcher_placeholder"></div>
  1036. <div class="version_switcher_placeholder"></div>
  1037. </li>
  1038. <li>
  1039. </li>
  1040. <li id="cpython-language-and-version">
  1041. <a href="../index.html">3.12.0 Documentation</a> &#187;
  1042. </li>
  1043. <li class="nav-item nav-item-1"><a href="index.html" >What’s New in Python</a> &#187;</li>
  1044. <li class="nav-item nav-item-this"><a href="">What’s New In Python 3.0</a></li>
  1045. <li class="right">
  1046. <div class="inline-search" role="search">
  1047. <form class="inline-search" action="../search.html" method="get">
  1048. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  1049. <input type="submit" value="Go" />
  1050. </form>
  1051. </div>
  1052. |
  1053. </li>
  1054. <li class="right">
  1055. <label class="theme-selector-label">
  1056. Theme
  1057. <select class="theme-selector" oninput="activateTheme(this.value)">
  1058. <option value="auto" selected>Auto</option>
  1059. <option value="light">Light</option>
  1060. <option value="dark">Dark</option>
  1061. </select>
  1062. </label> |</li>
  1063. </ul>
  1064. </div>
  1065. <div class="footer">
  1066. &copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
  1067. <br />
  1068. This page is licensed under the Python Software Foundation License Version 2.
  1069. <br />
  1070. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  1071. <br />
  1072. See <a href="/license.html">History and License</a> for more information.<br />
  1073. <br />
  1074. The Python Software Foundation is a non-profit corporation.
  1075. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  1076. <br />
  1077. <br />
  1078. Last updated on Oct 02, 2023.
  1079. <a href="/bugs.html">Found a bug</a>?
  1080. <br />
  1081. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
  1082. </div>
  1083. </body>
  1084. </html>