gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

910 行
73KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="2to3 — Automated Python 2 to 3 code translation" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/2to3.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will ha..." />
  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="2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will ha..." />
  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>2to3 — Automated Python 2 to 3 code translation &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="test — Regression tests package for Python" href="test.html" />
  33. <link rel="prev" title="unittest.mock — getting started" href="unittest.mock-examples.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/2to3.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">2to3 — Automated Python 2 to 3 code translation</a><ul>
  86. <li><a class="reference internal" href="#using-2to3">Using 2to3</a></li>
  87. <li><a class="reference internal" href="#fixers">Fixers</a></li>
  88. <li><a class="reference internal" href="#module-lib2to3"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code> — 2to3’s library</a></li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </div>
  93. <div>
  94. <h4>Previous topic</h4>
  95. <p class="topless"><a href="unittest.mock-examples.html"
  96. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">unittest.mock</span></code> — getting started</a></p>
  97. </div>
  98. <div>
  99. <h4>Next topic</h4>
  100. <p class="topless"><a href="test.html"
  101. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">test</span></code> — Regression tests package for Python</a></p>
  102. </div>
  103. <div role="note" aria-label="source link">
  104. <h3>This Page</h3>
  105. <ul class="this-page-menu">
  106. <li><a href="../bugs.html">Report a Bug</a></li>
  107. <li>
  108. <a href="https://github.com/python/cpython/blob/main/Doc/library/2to3.rst"
  109. rel="nofollow">Show Source
  110. </a>
  111. </li>
  112. </ul>
  113. </div>
  114. </nav>
  115. </div>
  116. </div>
  117. <div class="related" role="navigation" aria-label="related navigation">
  118. <h3>Navigation</h3>
  119. <ul>
  120. <li class="right" style="margin-right: 10px">
  121. <a href="../genindex.html" title="General Index"
  122. accesskey="I">index</a></li>
  123. <li class="right" >
  124. <a href="../py-modindex.html" title="Python Module Index"
  125. >modules</a> |</li>
  126. <li class="right" >
  127. <a href="test.html" title="test — Regression tests package for Python"
  128. accesskey="N">next</a> |</li>
  129. <li class="right" >
  130. <a href="unittest.mock-examples.html" title="unittest.mock — getting started"
  131. accesskey="P">previous</a> |</li>
  132. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  133. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  134. <li class="switchers">
  135. <div class="language_switcher_placeholder"></div>
  136. <div class="version_switcher_placeholder"></div>
  137. </li>
  138. <li>
  139. </li>
  140. <li id="cpython-language-and-version">
  141. <a href="../index.html">3.12.3 Documentation</a> &#187;
  142. </li>
  143. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  144. <li class="nav-item nav-item-2"><a href="development.html" accesskey="U">Development Tools</a> &#187;</li>
  145. <li class="nav-item nav-item-this"><a href="">2to3 — Automated Python 2 to 3 code translation</a></li>
  146. <li class="right">
  147. <div class="inline-search" role="search">
  148. <form class="inline-search" action="../search.html" method="get">
  149. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  150. <input type="submit" value="Go" />
  151. </form>
  152. </div>
  153. |
  154. </li>
  155. <li class="right">
  156. <label class="theme-selector-label">
  157. Theme
  158. <select class="theme-selector" oninput="activateTheme(this.value)">
  159. <option value="auto" selected>Auto</option>
  160. <option value="light">Light</option>
  161. <option value="dark">Dark</option>
  162. </select>
  163. </label> |</li>
  164. </ul>
  165. </div>
  166. <div class="document">
  167. <div class="documentwrapper">
  168. <div class="bodywrapper">
  169. <div class="body" role="main">
  170. <section id="to3-automated-python-2-to-3-code-translation">
  171. <span id="to3-reference"></span><h1>2to3 — Automated Python 2 to 3 code translation<a class="headerlink" href="#to3-automated-python-2-to-3-code-translation" title="Link to this heading">¶</a></h1>
  172. <p>2to3 is a Python program that reads Python 2.x source code and applies a series
  173. of <em>fixers</em> to transform it into valid Python 3.x code. The standard library
  174. contains a rich set of fixers that will handle almost all code. 2to3 supporting
  175. library <a class="reference internal" href="#module-lib2to3" title="lib2to3: The 2to3 library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code></a> is, however, a flexible and generic library, so it is
  176. possible to write your own fixers for 2to3.</p>
  177. <div class="deprecated-removed">
  178. <p><span class="versionmodified">Deprecated since version 3.11, will be removed in version 3.13: </span>The <code class="docutils literal notranslate"><span class="pre">lib2to3</span></code> module was marked pending for deprecation in Python 3.9
  179. (raising <a class="reference internal" href="exceptions.html#PendingDeprecationWarning" title="PendingDeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PendingDeprecationWarning</span></code></a> on import) and fully deprecated
  180. in Python 3.11 (raising <a class="reference internal" href="exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>). The <code class="docutils literal notranslate"><span class="pre">2to3</span></code> tool is
  181. part of that. It will be removed in Python 3.13.</p>
  182. </div>
  183. <section id="using-2to3">
  184. <span id="to3-using"></span><h2>Using 2to3<a class="headerlink" href="#using-2to3" title="Link to this heading">¶</a></h2>
  185. <p>2to3 will usually be installed with the Python interpreter as a script. It is
  186. also located in the <code class="file docutils literal notranslate"><span class="pre">Tools/scripts</span></code> directory of the Python root.</p>
  187. <p>2to3’s basic arguments are a list of files or directories to transform. The
  188. directories are recursively traversed for Python sources.</p>
  189. <p>Here is a sample Python 2.x source file, <code class="file docutils literal notranslate"><span class="pre">example.py</span></code>:</p>
  190. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">greet</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
  191. <span class="nb">print</span> <span class="s2">&quot;Hello, </span><span class="si">{0}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
  192. <span class="nb">print</span> <span class="s2">&quot;What&#39;s your name?&quot;</span>
  193. <span class="n">name</span> <span class="o">=</span> <span class="n">raw_input</span><span class="p">()</span>
  194. <span class="n">greet</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
  195. </pre></div>
  196. </div>
  197. <p>It can be converted to Python 3.x code via 2to3 on the command line:</p>
  198. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>example.py
  199. </pre></div>
  200. </div>
  201. <p>A diff against the original source file is printed. 2to3 can also write the
  202. needed modifications right back to the source file. (A backup of the original
  203. file is made unless <code class="xref std std-option docutils literal notranslate"><span class="pre">-n</span></code> is also given.) Writing the changes back is
  204. enabled with the <code class="xref std std-option docutils literal notranslate"><span class="pre">-w</span></code> flag:</p>
  205. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>-w<span class="w"> </span>example.py
  206. </pre></div>
  207. </div>
  208. <p>After transformation, <code class="file docutils literal notranslate"><span class="pre">example.py</span></code> looks like this:</p>
  209. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">greet</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
  210. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Hello, </span><span class="si">{0}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">))</span>
  211. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;What&#39;s your name?&quot;</span><span class="p">)</span>
  212. <span class="n">name</span> <span class="o">=</span> <span class="nb">input</span><span class="p">()</span>
  213. <span class="n">greet</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
  214. </pre></div>
  215. </div>
  216. <p>Comments and exact indentation are preserved throughout the translation process.</p>
  217. <p>By default, 2to3 runs a set of <a class="reference internal" href="#to3-fixers"><span class="std std-ref">predefined fixers</span></a>. The
  218. <code class="xref std std-option docutils literal notranslate"><span class="pre">-l</span></code> flag lists all available fixers. An explicit set of fixers to run
  219. can be given with <code class="xref std std-option docutils literal notranslate"><span class="pre">-f</span></code>. Likewise the <code class="xref std std-option docutils literal notranslate"><span class="pre">-x</span></code> explicitly disables a
  220. fixer. The following example runs only the <code class="docutils literal notranslate"><span class="pre">imports</span></code> and <code class="docutils literal notranslate"><span class="pre">has_key</span></code> fixers:</p>
  221. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>-f<span class="w"> </span>imports<span class="w"> </span>-f<span class="w"> </span>has_key<span class="w"> </span>example.py
  222. </pre></div>
  223. </div>
  224. <p>This command runs every fixer except the <code class="docutils literal notranslate"><span class="pre">apply</span></code> fixer:</p>
  225. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>-x<span class="w"> </span>apply<span class="w"> </span>example.py
  226. </pre></div>
  227. </div>
  228. <p>Some fixers are <em>explicit</em>, meaning they aren’t run by default and must be
  229. listed on the command line to be run. Here, in addition to the default fixers,
  230. the <code class="docutils literal notranslate"><span class="pre">idioms</span></code> fixer is run:</p>
  231. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>-f<span class="w"> </span>all<span class="w"> </span>-f<span class="w"> </span>idioms<span class="w"> </span>example.py
  232. </pre></div>
  233. </div>
  234. <p>Notice how passing <code class="docutils literal notranslate"><span class="pre">all</span></code> enables all default fixers.</p>
  235. <p>Sometimes 2to3 will find a place in your source code that needs to be changed,
  236. but 2to3 cannot fix automatically. In this case, 2to3 will print a warning
  237. beneath the diff for a file. You should address the warning in order to have
  238. compliant 3.x code.</p>
  239. <p>2to3 can also refactor doctests. To enable this mode, use the <code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code>
  240. flag. Note that <em>only</em> doctests will be refactored. This also doesn’t require
  241. the module to be valid Python. For example, doctest like examples in a reST
  242. document could also be refactored with this option.</p>
  243. <p>The <code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code> option enables output of more information on the translation
  244. process.</p>
  245. <p>Since some print statements can be parsed as function calls or statements, 2to3
  246. cannot always read files containing the print function. When 2to3 detects the
  247. presence of the <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">print_function</span></code> compiler directive, it
  248. modifies its internal grammar to interpret <a class="reference internal" href="functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a> as a function. This
  249. change can also be enabled manually with the <code class="xref std std-option docutils literal notranslate"><span class="pre">-p</span></code> flag. Use
  250. <code class="xref std std-option docutils literal notranslate"><span class="pre">-p</span></code> to run fixers on code that already has had its print statements
  251. converted. Also <code class="xref std std-option docutils literal notranslate"><span class="pre">-e</span></code> can be used to make <a class="reference internal" href="functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> a function.</p>
  252. <p>The <code class="xref std std-option docutils literal notranslate"><span class="pre">-o</span></code> or <code class="xref std std-option docutils literal notranslate"><span class="pre">--output-dir</span></code> option allows specification of an
  253. alternate directory for processed output files to be written to. The
  254. <code class="xref std std-option docutils literal notranslate"><span class="pre">-n</span></code> flag is required when using this as backup files do not make sense
  255. when not overwriting the input files.</p>
  256. <div class="versionadded">
  257. <p><span class="versionmodified added">New in version 3.2.3: </span>The <code class="xref std std-option docutils literal notranslate"><span class="pre">-o</span></code> option was added.</p>
  258. </div>
  259. <p>The <code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code> or <code class="xref std std-option docutils literal notranslate"><span class="pre">--write-unchanged-files</span></code> flag tells 2to3 to always
  260. write output files even if no changes were required to the file. This is most
  261. useful with <code class="xref std std-option docutils literal notranslate"><span class="pre">-o</span></code> so that an entire Python source tree is copied with
  262. translation from one directory to another.
  263. This option implies the <code class="xref std std-option docutils literal notranslate"><span class="pre">-w</span></code> flag as it would not make sense otherwise.</p>
  264. <div class="versionadded">
  265. <p><span class="versionmodified added">New in version 3.2.3: </span>The <code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code> flag was added.</p>
  266. </div>
  267. <p>The <code class="xref std std-option docutils literal notranslate"><span class="pre">--add-suffix</span></code> option specifies a string to append to all output
  268. filenames. The <code class="xref std std-option docutils literal notranslate"><span class="pre">-n</span></code> flag is required when specifying this as backups
  269. are not necessary when writing to different filenames. Example:</p>
  270. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>-n<span class="w"> </span>-W<span class="w"> </span>--add-suffix<span class="o">=</span><span class="m">3</span><span class="w"> </span>example.py
  271. </pre></div>
  272. </div>
  273. <p>Will cause a converted file named <code class="docutils literal notranslate"><span class="pre">example.py3</span></code> to be written.</p>
  274. <div class="versionadded">
  275. <p><span class="versionmodified added">New in version 3.2.3: </span>The <code class="xref std std-option docutils literal notranslate"><span class="pre">--add-suffix</span></code> option was added.</p>
  276. </div>
  277. <p>To translate an entire project from one directory tree to another use:</p>
  278. <div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>2to3<span class="w"> </span>--output-dir<span class="o">=</span>python3-version/mycode<span class="w"> </span>-W<span class="w"> </span>-n<span class="w"> </span>python2-version/mycode
  279. </pre></div>
  280. </div>
  281. </section>
  282. <section id="fixers">
  283. <span id="to3-fixers"></span><h2>Fixers<a class="headerlink" href="#fixers" title="Link to this heading">¶</a></h2>
  284. <p>Each step of transforming code is encapsulated in a fixer. The command <code class="docutils literal notranslate"><span class="pre">2to3</span>
  285. <span class="pre">-l</span></code> lists them. As <a class="reference internal" href="#to3-using"><span class="std std-ref">documented above</span></a>, each can be turned on
  286. and off individually. They are described here in more detail.</p>
  287. <dl class="std 2to3fixer">
  288. <dt class="sig sig-object std" id="to3fixer-apply">
  289. <span class="sig-name descname"><span class="pre">apply</span></span><a class="headerlink" href="#to3fixer-apply" title="Link to this definition">¶</a></dt>
  290. <dd><p>Removes usage of <code class="xref py py-func docutils literal notranslate"><span class="pre">apply()</span></code>. For example <code class="docutils literal notranslate"><span class="pre">apply(function,</span> <span class="pre">*args,</span>
  291. <span class="pre">**kwargs)</span></code> is converted to <code class="docutils literal notranslate"><span class="pre">function(*args,</span> <span class="pre">**kwargs)</span></code>.</p>
  292. </dd></dl>
  293. <dl class="std 2to3fixer">
  294. <dt class="sig sig-object std" id="to3fixer-asserts">
  295. <span class="sig-name descname"><span class="pre">asserts</span></span><a class="headerlink" href="#to3fixer-asserts" title="Link to this definition">¶</a></dt>
  296. <dd><p>Replaces deprecated <a class="reference internal" href="unittest.html#module-unittest" title="unittest: Unit testing framework for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">unittest</span></code></a> method names with the correct ones.</p>
  297. <table class="docutils align-default">
  298. <thead>
  299. <tr class="row-odd"><th class="head"><p>From</p></th>
  300. <th class="head"><p>To</p></th>
  301. </tr>
  302. </thead>
  303. <tbody>
  304. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failUnlessEqual(a,</span> <span class="pre">b)</span></code></p></td>
  305. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertEqual" title="unittest.TestCase.assertEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  306. </tr>
  307. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">assertEquals(a,</span> <span class="pre">b)</span></code></p></td>
  308. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertEqual" title="unittest.TestCase.assertEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  309. </tr>
  310. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failIfEqual(a,</span> <span class="pre">b)</span></code></p></td>
  311. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertNotEqual" title="unittest.TestCase.assertNotEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertNotEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  312. </tr>
  313. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">assertNotEquals(a,</span> <span class="pre">b)</span></code></p></td>
  314. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertNotEqual" title="unittest.TestCase.assertNotEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertNotEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  315. </tr>
  316. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failUnless(a)</span></code></p></td>
  317. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertTrue" title="unittest.TestCase.assertTrue"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertTrue(a)</span></code></a></p></td>
  318. </tr>
  319. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">assert_(a)</span></code></p></td>
  320. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertTrue" title="unittest.TestCase.assertTrue"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertTrue(a)</span></code></a></p></td>
  321. </tr>
  322. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failIf(a)</span></code></p></td>
  323. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertFalse" title="unittest.TestCase.assertFalse"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertFalse(a)</span></code></a></p></td>
  324. </tr>
  325. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">failUnlessRaises(exc,</span> <span class="pre">cal)</span></code></p></td>
  326. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertRaises" title="unittest.TestCase.assertRaises"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertRaises(exc,</span> <span class="pre">cal)</span></code></a></p></td>
  327. </tr>
  328. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failUnlessAlmostEqual(a,</span> <span class="pre">b)</span></code></p></td>
  329. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertAlmostEqual" title="unittest.TestCase.assertAlmostEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertAlmostEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  330. </tr>
  331. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">assertAlmostEquals(a,</span> <span class="pre">b)</span></code></p></td>
  332. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertAlmostEqual" title="unittest.TestCase.assertAlmostEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertAlmostEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  333. </tr>
  334. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">failIfAlmostEqual(a,</span> <span class="pre">b)</span></code></p></td>
  335. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertNotAlmostEqual" title="unittest.TestCase.assertNotAlmostEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertNotAlmostEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  336. </tr>
  337. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">assertNotAlmostEquals(a,</span> <span class="pre">b)</span></code></p></td>
  338. <td><p><a class="reference internal" href="unittest.html#unittest.TestCase.assertNotAlmostEqual" title="unittest.TestCase.assertNotAlmostEqual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertNotAlmostEqual(a,</span> <span class="pre">b)</span></code></a></p></td>
  339. </tr>
  340. </tbody>
  341. </table>
  342. </dd></dl>
  343. <dl class="std 2to3fixer">
  344. <dt class="sig sig-object std" id="to3fixer-basestring">
  345. <span class="sig-name descname"><span class="pre">basestring</span></span><a class="headerlink" href="#to3fixer-basestring" title="Link to this definition">¶</a></dt>
  346. <dd><p>Converts <code class="xref py py-class docutils literal notranslate"><span class="pre">basestring</span></code> to <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p>
  347. </dd></dl>
  348. <dl class="std 2to3fixer">
  349. <dt class="sig sig-object std" id="to3fixer-buffer">
  350. <span class="sig-name descname"><span class="pre">buffer</span></span><a class="headerlink" href="#to3fixer-buffer" title="Link to this definition">¶</a></dt>
  351. <dd><p>Converts <code class="xref py py-class docutils literal notranslate"><span class="pre">buffer</span></code> to <a class="reference internal" href="stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a>. This fixer is optional
  352. because the <a class="reference internal" href="stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a> API is similar but not exactly the same as
  353. that of <code class="xref py py-class docutils literal notranslate"><span class="pre">buffer</span></code>.</p>
  354. </dd></dl>
  355. <dl class="std 2to3fixer">
  356. <dt class="sig sig-object std" id="to3fixer-dict">
  357. <span class="sig-name descname"><span class="pre">dict</span></span><a class="headerlink" href="#to3fixer-dict" title="Link to this definition">¶</a></dt>
  358. <dd><p>Fixes dictionary iteration methods. <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.iteritems()</span></code> is converted to
  359. <a class="reference internal" href="stdtypes.html#dict.items" title="dict.items"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.items()</span></code></a>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.iterkeys()</span></code> to <a class="reference internal" href="stdtypes.html#dict.keys" title="dict.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.keys()</span></code></a>, and
  360. <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.itervalues()</span></code> to <a class="reference internal" href="stdtypes.html#dict.values" title="dict.values"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.values()</span></code></a>. Similarly,
  361. <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.viewitems()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.viewkeys()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.viewvalues()</span></code> are
  362. converted respectively to <a class="reference internal" href="stdtypes.html#dict.items" title="dict.items"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.items()</span></code></a>, <a class="reference internal" href="stdtypes.html#dict.keys" title="dict.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.keys()</span></code></a> and
  363. <a class="reference internal" href="stdtypes.html#dict.values" title="dict.values"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.values()</span></code></a>. It also wraps existing usages of <a class="reference internal" href="stdtypes.html#dict.items" title="dict.items"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.items()</span></code></a>,
  364. <a class="reference internal" href="stdtypes.html#dict.keys" title="dict.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.keys()</span></code></a>, and <a class="reference internal" href="stdtypes.html#dict.values" title="dict.values"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.values()</span></code></a> in a call to <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>.</p>
  365. </dd></dl>
  366. <dl class="std 2to3fixer">
  367. <dt class="sig sig-object std" id="to3fixer-except">
  368. <span class="sig-name descname"><span class="pre">except</span></span><a class="headerlink" href="#to3fixer-except" title="Link to this definition">¶</a></dt>
  369. <dd><p>Converts <code class="docutils literal notranslate"><span class="pre">except</span> <span class="pre">X,</span> <span class="pre">T</span></code> to <code class="docutils literal notranslate"><span class="pre">except</span> <span class="pre">X</span> <span class="pre">as</span> <span class="pre">T</span></code>.</p>
  370. </dd></dl>
  371. <dl class="std 2to3fixer">
  372. <dt class="sig sig-object std" id="to3fixer-exec">
  373. <span class="sig-name descname"><span class="pre">exec</span></span><a class="headerlink" href="#to3fixer-exec" title="Link to this definition">¶</a></dt>
  374. <dd><p>Converts the <code class="docutils literal notranslate"><span class="pre">exec</span></code> statement to the <a class="reference internal" href="functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> function.</p>
  375. </dd></dl>
  376. <dl class="std 2to3fixer">
  377. <dt class="sig sig-object std" id="to3fixer-execfile">
  378. <span class="sig-name descname"><span class="pre">execfile</span></span><a class="headerlink" href="#to3fixer-execfile" title="Link to this definition">¶</a></dt>
  379. <dd><p>Removes usage of <code class="xref py py-func docutils literal notranslate"><span class="pre">execfile()</span></code>. The argument to <code class="xref py py-func docutils literal notranslate"><span class="pre">execfile()</span></code> is
  380. wrapped in calls to <a class="reference internal" href="functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>, <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a>, and <a class="reference internal" href="functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a>.</p>
  381. </dd></dl>
  382. <dl class="std 2to3fixer">
  383. <dt class="sig sig-object std" id="to3fixer-exitfunc">
  384. <span class="sig-name descname"><span class="pre">exitfunc</span></span><a class="headerlink" href="#to3fixer-exitfunc" title="Link to this definition">¶</a></dt>
  385. <dd><p>Changes assignment of <code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.exitfunc</span></code> to use of the <a class="reference internal" href="atexit.html#module-atexit" title="atexit: Register and execute cleanup functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">atexit</span></code></a>
  386. module.</p>
  387. </dd></dl>
  388. <dl class="std 2to3fixer">
  389. <dt class="sig sig-object std" id="to3fixer-filter">
  390. <span class="sig-name descname"><span class="pre">filter</span></span><a class="headerlink" href="#to3fixer-filter" title="Link to this definition">¶</a></dt>
  391. <dd><p>Wraps <a class="reference internal" href="functions.html#filter" title="filter"><code class="xref py py-func docutils literal notranslate"><span class="pre">filter()</span></code></a> usage in a <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> call.</p>
  392. </dd></dl>
  393. <dl class="std 2to3fixer">
  394. <dt class="sig sig-object std" id="to3fixer-funcattrs">
  395. <span class="sig-name descname"><span class="pre">funcattrs</span></span><a class="headerlink" href="#to3fixer-funcattrs" title="Link to this definition">¶</a></dt>
  396. <dd><p>Fixes function attributes that have been renamed. For example,
  397. <code class="docutils literal notranslate"><span class="pre">my_function.func_closure</span></code> is converted to <code class="docutils literal notranslate"><span class="pre">my_function.__closure__</span></code>.</p>
  398. </dd></dl>
  399. <dl class="std 2to3fixer">
  400. <dt class="sig sig-object std" id="to3fixer-future">
  401. <span class="sig-name descname"><span class="pre">future</span></span><a class="headerlink" href="#to3fixer-future" title="Link to this definition">¶</a></dt>
  402. <dd><p>Removes <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">new_feature</span></code> statements.</p>
  403. </dd></dl>
  404. <dl class="std 2to3fixer">
  405. <dt class="sig sig-object std" id="to3fixer-getcwdu">
  406. <span class="sig-name descname"><span class="pre">getcwdu</span></span><a class="headerlink" href="#to3fixer-getcwdu" title="Link to this definition">¶</a></dt>
  407. <dd><p>Renames <code class="xref py py-func docutils literal notranslate"><span class="pre">os.getcwdu()</span></code> to <a class="reference internal" href="os.html#os.getcwd" title="os.getcwd"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.getcwd()</span></code></a>.</p>
  408. </dd></dl>
  409. <dl class="std 2to3fixer">
  410. <dt class="sig sig-object std" id="to3fixer-has_key">
  411. <span class="sig-name descname"><span class="pre">has_key</span></span><a class="headerlink" href="#to3fixer-has_key" title="Link to this definition">¶</a></dt>
  412. <dd><p>Changes <code class="docutils literal notranslate"><span class="pre">dict.has_key(key)</span></code> to <code class="docutils literal notranslate"><span class="pre">key</span> <span class="pre">in</span> <span class="pre">dict</span></code>.</p>
  413. </dd></dl>
  414. <dl class="std 2to3fixer">
  415. <dt class="sig sig-object std" id="to3fixer-idioms">
  416. <span class="sig-name descname"><span class="pre">idioms</span></span><a class="headerlink" href="#to3fixer-idioms" title="Link to this definition">¶</a></dt>
  417. <dd><p>This optional fixer performs several transformations that make Python code
  418. more idiomatic. Type comparisons like <code class="docutils literal notranslate"><span class="pre">type(x)</span> <span class="pre">is</span> <span class="pre">SomeClass</span></code> and
  419. <code class="docutils literal notranslate"><span class="pre">type(x)</span> <span class="pre">==</span> <span class="pre">SomeClass</span></code> are converted to <code class="docutils literal notranslate"><span class="pre">isinstance(x,</span> <span class="pre">SomeClass)</span></code>.
  420. <code class="docutils literal notranslate"><span class="pre">while</span> <span class="pre">1</span></code> becomes <code class="docutils literal notranslate"><span class="pre">while</span> <span class="pre">True</span></code>. This fixer also tries to make use of
  421. <a class="reference internal" href="functions.html#sorted" title="sorted"><code class="xref py py-func docutils literal notranslate"><span class="pre">sorted()</span></code></a> in appropriate places. For example, this block</p>
  422. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">L</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">some_iterable</span><span class="p">)</span>
  423. <span class="n">L</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
  424. </pre></div>
  425. </div>
  426. <p>is changed to</p>
  427. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">L</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">some_iterable</span><span class="p">)</span>
  428. </pre></div>
  429. </div>
  430. </dd></dl>
  431. <dl class="std 2to3fixer">
  432. <dt class="sig sig-object std" id="to3fixer-import">
  433. <span class="sig-name descname"><span class="pre">import</span></span><a class="headerlink" href="#to3fixer-import" title="Link to this definition">¶</a></dt>
  434. <dd><p>Detects sibling imports and converts them to relative imports.</p>
  435. </dd></dl>
  436. <dl class="std 2to3fixer">
  437. <dt class="sig sig-object std" id="to3fixer-imports">
  438. <span class="sig-name descname"><span class="pre">imports</span></span><a class="headerlink" href="#to3fixer-imports" title="Link to this definition">¶</a></dt>
  439. <dd><p>Handles module renames in the standard library.</p>
  440. </dd></dl>
  441. <dl class="std 2to3fixer">
  442. <dt class="sig sig-object std" id="to3fixer-imports2">
  443. <span class="sig-name descname"><span class="pre">imports2</span></span><a class="headerlink" href="#to3fixer-imports2" title="Link to this definition">¶</a></dt>
  444. <dd><p>Handles other modules renames in the standard library. It is separate from
  445. the <a class="reference internal" href="#to3fixer-imports"><code class="xref std std-2to3fixer docutils literal notranslate"><span class="pre">imports</span></code></a> fixer only because of technical limitations.</p>
  446. </dd></dl>
  447. <dl class="std 2to3fixer">
  448. <dt class="sig sig-object std" id="to3fixer-input">
  449. <span class="sig-name descname"><span class="pre">input</span></span><a class="headerlink" href="#to3fixer-input" title="Link to this definition">¶</a></dt>
  450. <dd><p>Converts <code class="docutils literal notranslate"><span class="pre">input(prompt)</span></code> to <code class="docutils literal notranslate"><span class="pre">eval(input(prompt))</span></code>.</p>
  451. </dd></dl>
  452. <dl class="std 2to3fixer">
  453. <dt class="sig sig-object std" id="to3fixer-intern">
  454. <span class="sig-name descname"><span class="pre">intern</span></span><a class="headerlink" href="#to3fixer-intern" title="Link to this definition">¶</a></dt>
  455. <dd><p>Converts <code class="xref py py-func docutils literal notranslate"><span class="pre">intern()</span></code> to <a class="reference internal" href="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>
  456. </dd></dl>
  457. <dl class="std 2to3fixer">
  458. <dt class="sig sig-object std" id="to3fixer-isinstance">
  459. <span class="sig-name descname"><span class="pre">isinstance</span></span><a class="headerlink" href="#to3fixer-isinstance" title="Link to this definition">¶</a></dt>
  460. <dd><p>Fixes duplicate types in the second argument of <a class="reference internal" href="functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a>. For
  461. example, <code class="docutils literal notranslate"><span class="pre">isinstance(x,</span> <span class="pre">(int,</span> <span class="pre">int))</span></code> is converted to <code class="docutils literal notranslate"><span class="pre">isinstance(x,</span>
  462. <span class="pre">int)</span></code> and <code class="docutils literal notranslate"><span class="pre">isinstance(x,</span> <span class="pre">(int,</span> <span class="pre">float,</span> <span class="pre">int))</span></code> is converted to
  463. <code class="docutils literal notranslate"><span class="pre">isinstance(x,</span> <span class="pre">(int,</span> <span class="pre">float))</span></code>.</p>
  464. </dd></dl>
  465. <dl class="std 2to3fixer">
  466. <dt class="sig sig-object std" id="to3fixer-itertools_imports">
  467. <span class="sig-name descname"><span class="pre">itertools_imports</span></span><a class="headerlink" href="#to3fixer-itertools_imports" title="Link to this definition">¶</a></dt>
  468. <dd><p>Removes imports of <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.ifilter()</span></code>, <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.izip()</span></code>, and
  469. <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.imap()</span></code>. Imports of <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.ifilterfalse()</span></code> are also
  470. changed to <a class="reference internal" href="itertools.html#itertools.filterfalse" title="itertools.filterfalse"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.filterfalse()</span></code></a>.</p>
  471. </dd></dl>
  472. <dl class="std 2to3fixer">
  473. <dt class="sig sig-object std" id="to3fixer-itertools">
  474. <span class="sig-name descname"><span class="pre">itertools</span></span><a class="headerlink" href="#to3fixer-itertools" title="Link to this definition">¶</a></dt>
  475. <dd><p>Changes usage of <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.ifilter()</span></code>, <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.izip()</span></code>, and
  476. <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.imap()</span></code> to their built-in equivalents.
  477. <code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.ifilterfalse()</span></code> is changed to <a class="reference internal" href="itertools.html#itertools.filterfalse" title="itertools.filterfalse"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.filterfalse()</span></code></a>.</p>
  478. </dd></dl>
  479. <dl class="std 2to3fixer">
  480. <dt class="sig sig-object std" id="to3fixer-long">
  481. <span class="sig-name descname"><span class="pre">long</span></span><a class="headerlink" href="#to3fixer-long" title="Link to this definition">¶</a></dt>
  482. <dd><p>Renames <code class="xref py py-class docutils literal notranslate"><span class="pre">long</span></code> to <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p>
  483. </dd></dl>
  484. <dl class="std 2to3fixer">
  485. <dt class="sig sig-object std" id="to3fixer-map">
  486. <span class="sig-name descname"><span class="pre">map</span></span><a class="headerlink" href="#to3fixer-map" title="Link to this definition">¶</a></dt>
  487. <dd><p>Wraps <a class="reference internal" href="functions.html#map" title="map"><code class="xref py py-func docutils literal notranslate"><span class="pre">map()</span></code></a> in a <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> call. It also changes <code class="docutils literal notranslate"><span class="pre">map(None,</span> <span class="pre">x)</span></code>
  488. to <code class="docutils literal notranslate"><span class="pre">list(x)</span></code>. Using <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">future_builtins</span> <span class="pre">import</span> <span class="pre">map</span></code> disables this
  489. fixer.</p>
  490. </dd></dl>
  491. <dl class="std 2to3fixer">
  492. <dt class="sig sig-object std" id="to3fixer-metaclass">
  493. <span class="sig-name descname"><span class="pre">metaclass</span></span><a class="headerlink" href="#to3fixer-metaclass" title="Link to this definition">¶</a></dt>
  494. <dd><p>Converts the old metaclass syntax (<code class="docutils literal notranslate"><span class="pre">__metaclass__</span> <span class="pre">=</span> <span class="pre">Meta</span></code> in the class
  495. body) to the new (<code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">X(metaclass=Meta)</span></code>).</p>
  496. </dd></dl>
  497. <dl class="std 2to3fixer">
  498. <dt class="sig sig-object std" id="to3fixer-methodattrs">
  499. <span class="sig-name descname"><span class="pre">methodattrs</span></span><a class="headerlink" href="#to3fixer-methodattrs" title="Link to this definition">¶</a></dt>
  500. <dd><p>Fixes old method attribute names. For example, <code class="docutils literal notranslate"><span class="pre">meth.im_func</span></code> is converted
  501. to <code class="docutils literal notranslate"><span class="pre">meth.__func__</span></code>.</p>
  502. </dd></dl>
  503. <dl class="std 2to3fixer">
  504. <dt class="sig sig-object std" id="to3fixer-ne">
  505. <span class="sig-name descname"><span class="pre">ne</span></span><a class="headerlink" href="#to3fixer-ne" title="Link to this definition">¶</a></dt>
  506. <dd><p>Converts the old not-equal syntax, <code class="docutils literal notranslate"><span class="pre">&lt;&gt;</span></code>, to <code class="docutils literal notranslate"><span class="pre">!=</span></code>.</p>
  507. </dd></dl>
  508. <dl class="std 2to3fixer">
  509. <dt class="sig sig-object std" id="to3fixer-next">
  510. <span class="sig-name descname"><span class="pre">next</span></span><a class="headerlink" href="#to3fixer-next" title="Link to this definition">¶</a></dt>
  511. <dd><p>Converts the use of iterator’s <code class="xref py py-meth docutils literal notranslate"><span class="pre">next()</span></code> methods to the
  512. <a class="reference internal" href="functions.html#next" title="next"><code class="xref py py-func docutils literal notranslate"><span class="pre">next()</span></code></a> function. It also renames <a class="reference internal" href="functions.html#next" title="next"><code class="xref py py-meth docutils literal notranslate"><span class="pre">next()</span></code></a> methods to
  513. <a class="reference internal" href="stdtypes.html#iterator.__next__" title="iterator.__next__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__next__()</span></code></a>.</p>
  514. </dd></dl>
  515. <dl class="std 2to3fixer">
  516. <dt class="sig sig-object std" id="to3fixer-nonzero">
  517. <span class="sig-name descname"><span class="pre">nonzero</span></span><a class="headerlink" href="#to3fixer-nonzero" title="Link to this definition">¶</a></dt>
  518. <dd><p>Renames definitions of methods called <code class="xref py py-meth docutils literal notranslate"><span class="pre">__nonzero__()</span></code>
  519. to <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>
  520. </dd></dl>
  521. <dl class="std 2to3fixer">
  522. <dt class="sig sig-object std" id="to3fixer-numliterals">
  523. <span class="sig-name descname"><span class="pre">numliterals</span></span><a class="headerlink" href="#to3fixer-numliterals" title="Link to this definition">¶</a></dt>
  524. <dd><p>Converts octal literals into the new syntax.</p>
  525. </dd></dl>
  526. <dl class="std 2to3fixer">
  527. <dt class="sig sig-object std" id="to3fixer-operator">
  528. <span class="sig-name descname"><span class="pre">operator</span></span><a class="headerlink" href="#to3fixer-operator" title="Link to this definition">¶</a></dt>
  529. <dd><p>Converts calls to various functions in the <a class="reference internal" href="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 to other,
  530. but equivalent, function calls. When needed, the appropriate <code class="docutils literal notranslate"><span class="pre">import</span></code>
  531. statements are added, e.g. <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">collections.abc</span></code>. The following mapping
  532. are made:</p>
  533. <table class="docutils align-default">
  534. <thead>
  535. <tr class="row-odd"><th class="head"><p>From</p></th>
  536. <th class="head"><p>To</p></th>
  537. </tr>
  538. </thead>
  539. <tbody>
  540. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">operator.isCallable(obj)</span></code></p></td>
  541. <td><p><code class="docutils literal notranslate"><span class="pre">callable(obj)</span></code></p></td>
  542. </tr>
  543. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">operator.sequenceIncludes(obj)</span></code></p></td>
  544. <td><p><code class="docutils literal notranslate"><span class="pre">operator.contains(obj)</span></code></p></td>
  545. </tr>
  546. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">operator.isSequenceType(obj)</span></code></p></td>
  547. <td><p><code class="docutils literal notranslate"><span class="pre">isinstance(obj,</span> <span class="pre">collections.abc.Sequence)</span></code></p></td>
  548. </tr>
  549. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">operator.isMappingType(obj)</span></code></p></td>
  550. <td><p><code class="docutils literal notranslate"><span class="pre">isinstance(obj,</span> <span class="pre">collections.abc.Mapping)</span></code></p></td>
  551. </tr>
  552. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">operator.isNumberType(obj)</span></code></p></td>
  553. <td><p><code class="docutils literal notranslate"><span class="pre">isinstance(obj,</span> <span class="pre">numbers.Number)</span></code></p></td>
  554. </tr>
  555. <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">operator.repeat(obj,</span> <span class="pre">n)</span></code></p></td>
  556. <td><p><code class="docutils literal notranslate"><span class="pre">operator.mul(obj,</span> <span class="pre">n)</span></code></p></td>
  557. </tr>
  558. <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">operator.irepeat(obj,</span> <span class="pre">n)</span></code></p></td>
  559. <td><p><code class="docutils literal notranslate"><span class="pre">operator.imul(obj,</span> <span class="pre">n)</span></code></p></td>
  560. </tr>
  561. </tbody>
  562. </table>
  563. </dd></dl>
  564. <dl class="std 2to3fixer">
  565. <dt class="sig sig-object std" id="to3fixer-paren">
  566. <span class="sig-name descname"><span class="pre">paren</span></span><a class="headerlink" href="#to3fixer-paren" title="Link to this definition">¶</a></dt>
  567. <dd><p>Add extra parenthesis where they are required in list comprehensions. For
  568. example, <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">1,</span> <span class="pre">2]</span></code> becomes <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">(1,</span> <span class="pre">2)]</span></code>.</p>
  569. </dd></dl>
  570. <dl class="std 2to3fixer">
  571. <dt class="sig sig-object std" id="to3fixer-print">
  572. <span class="sig-name descname"><span class="pre">print</span></span><a class="headerlink" href="#to3fixer-print" title="Link to this definition">¶</a></dt>
  573. <dd><p>Converts the <code class="docutils literal notranslate"><span class="pre">print</span></code> statement to the <a class="reference internal" href="functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a> function.</p>
  574. </dd></dl>
  575. <dl class="std 2to3fixer">
  576. <dt class="sig sig-object std" id="to3fixer-raise">
  577. <span class="sig-name descname"><span class="pre">raise</span></span><a class="headerlink" href="#to3fixer-raise" title="Link to this definition">¶</a></dt>
  578. <dd><p>Converts <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">E,</span> <span class="pre">V</span></code> to <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">E(V)</span></code>, and <code class="docutils literal notranslate"><span class="pre">raise</span> <span class="pre">E,</span> <span class="pre">V,</span> <span class="pre">T</span></code> to <code class="docutils literal notranslate"><span class="pre">raise</span>
  579. <span class="pre">E(V).with_traceback(T)</span></code>. If <code class="docutils literal notranslate"><span class="pre">E</span></code> is a tuple, the translation will be
  580. incorrect because substituting tuples for exceptions has been removed in 3.0.</p>
  581. </dd></dl>
  582. <dl class="std 2to3fixer">
  583. <dt class="sig sig-object std" id="to3fixer-raw_input">
  584. <span class="sig-name descname"><span class="pre">raw_input</span></span><a class="headerlink" href="#to3fixer-raw_input" title="Link to this definition">¶</a></dt>
  585. <dd><p>Converts <code class="xref py py-func docutils literal notranslate"><span class="pre">raw_input()</span></code> to <a class="reference internal" href="functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a>.</p>
  586. </dd></dl>
  587. <dl class="std 2to3fixer">
  588. <dt class="sig sig-object std" id="to3fixer-reduce">
  589. <span class="sig-name descname"><span class="pre">reduce</span></span><a class="headerlink" href="#to3fixer-reduce" title="Link to this definition">¶</a></dt>
  590. <dd><p>Handles the move of <code class="xref py py-func docutils literal notranslate"><span class="pre">reduce()</span></code> to <a class="reference internal" href="functools.html#functools.reduce" title="functools.reduce"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.reduce()</span></code></a>.</p>
  591. </dd></dl>
  592. <dl class="std 2to3fixer">
  593. <dt class="sig sig-object std" id="to3fixer-reload">
  594. <span class="sig-name descname"><span class="pre">reload</span></span><a class="headerlink" href="#to3fixer-reload" title="Link to this definition">¶</a></dt>
  595. <dd><p>Converts <code class="xref py py-func docutils literal notranslate"><span class="pre">reload()</span></code> to <a class="reference internal" href="importlib.html#importlib.reload" title="importlib.reload"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.reload()</span></code></a>.</p>
  596. </dd></dl>
  597. <dl class="std 2to3fixer">
  598. <dt class="sig sig-object std" id="to3fixer-renames">
  599. <span class="sig-name descname"><span class="pre">renames</span></span><a class="headerlink" href="#to3fixer-renames" title="Link to this definition">¶</a></dt>
  600. <dd><p>Changes <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxint</span></code> to <a class="reference internal" href="sys.html#sys.maxsize" title="sys.maxsize"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxsize</span></code></a>.</p>
  601. </dd></dl>
  602. <dl class="std 2to3fixer">
  603. <dt class="sig sig-object std" id="to3fixer-repr">
  604. <span class="sig-name descname"><span class="pre">repr</span></span><a class="headerlink" href="#to3fixer-repr" title="Link to this definition">¶</a></dt>
  605. <dd><p>Replaces backtick repr with the <a class="reference internal" href="functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> function.</p>
  606. </dd></dl>
  607. <dl class="std 2to3fixer">
  608. <dt class="sig sig-object std" id="to3fixer-set_literal">
  609. <span class="sig-name descname"><span class="pre">set_literal</span></span><a class="headerlink" href="#to3fixer-set_literal" title="Link to this definition">¶</a></dt>
  610. <dd><p>Replaces use of the <a class="reference internal" href="stdtypes.html#set" title="set"><code class="xref py py-class docutils literal notranslate"><span class="pre">set</span></code></a> constructor with set literals. This fixer
  611. is optional.</p>
  612. </dd></dl>
  613. <dl class="std 2to3fixer">
  614. <dt class="sig sig-object std" id="to3fixer-standarderror">
  615. <span class="sig-name descname"><span class="pre">standarderror</span></span><a class="headerlink" href="#to3fixer-standarderror" title="Link to this definition">¶</a></dt>
  616. <dd><p>Renames <code class="xref py py-exc docutils literal notranslate"><span class="pre">StandardError</span></code> to <a class="reference internal" href="exceptions.html#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>.</p>
  617. </dd></dl>
  618. <dl class="std 2to3fixer">
  619. <dt class="sig sig-object std" id="to3fixer-sys_exc">
  620. <span class="sig-name descname"><span class="pre">sys_exc</span></span><a class="headerlink" href="#to3fixer-sys_exc" title="Link to this definition">¶</a></dt>
  621. <dd><p>Changes the deprecated <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_value</span></code>, <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_type</span></code>,
  622. <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exc_traceback</span></code> to use <a class="reference internal" href="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>.</p>
  623. </dd></dl>
  624. <dl class="std 2to3fixer">
  625. <dt class="sig sig-object std" id="to3fixer-throw">
  626. <span class="sig-name descname"><span class="pre">throw</span></span><a class="headerlink" href="#to3fixer-throw" title="Link to this definition">¶</a></dt>
  627. <dd><p>Fixes the API change in generator’s <code class="xref py py-meth docutils literal notranslate"><span class="pre">throw()</span></code> method.</p>
  628. </dd></dl>
  629. <dl class="std 2to3fixer">
  630. <dt class="sig sig-object std" id="to3fixer-tuple_params">
  631. <span class="sig-name descname"><span class="pre">tuple_params</span></span><a class="headerlink" href="#to3fixer-tuple_params" title="Link to this definition">¶</a></dt>
  632. <dd><p>Removes implicit tuple parameter unpacking. This fixer inserts temporary
  633. variables.</p>
  634. </dd></dl>
  635. <dl class="std 2to3fixer">
  636. <dt class="sig sig-object std" id="to3fixer-types">
  637. <span class="sig-name descname"><span class="pre">types</span></span><a class="headerlink" href="#to3fixer-types" title="Link to this definition">¶</a></dt>
  638. <dd><p>Fixes code broken from the removal of some members in the <a class="reference internal" href="types.html#module-types" title="types: Names for built-in types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">types</span></code></a>
  639. module.</p>
  640. </dd></dl>
  641. <dl class="std 2to3fixer">
  642. <dt class="sig sig-object std" id="to3fixer-unicode">
  643. <span class="sig-name descname"><span class="pre">unicode</span></span><a class="headerlink" href="#to3fixer-unicode" title="Link to this definition">¶</a></dt>
  644. <dd><p>Renames <code class="xref py py-class docutils literal notranslate"><span class="pre">unicode</span></code> to <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p>
  645. </dd></dl>
  646. <dl class="std 2to3fixer">
  647. <dt class="sig sig-object std" id="to3fixer-urllib">
  648. <span class="sig-name descname"><span class="pre">urllib</span></span><a class="headerlink" href="#to3fixer-urllib" title="Link to this definition">¶</a></dt>
  649. <dd><p>Handles the rename of <a class="reference internal" href="urllib.html#module-urllib" title="urllib"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib</span></code></a> and <code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib2</span></code> to the <a class="reference internal" href="urllib.html#module-urllib" title="urllib"><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib</span></code></a>
  650. package.</p>
  651. </dd></dl>
  652. <dl class="std 2to3fixer">
  653. <dt class="sig sig-object std" id="to3fixer-ws_comma">
  654. <span class="sig-name descname"><span class="pre">ws_comma</span></span><a class="headerlink" href="#to3fixer-ws_comma" title="Link to this definition">¶</a></dt>
  655. <dd><p>Removes excess whitespace from comma separated items. This fixer is
  656. optional.</p>
  657. </dd></dl>
  658. <dl class="std 2to3fixer">
  659. <dt class="sig sig-object std" id="to3fixer-xrange">
  660. <span class="sig-name descname"><span class="pre">xrange</span></span><a class="headerlink" href="#to3fixer-xrange" title="Link to this definition">¶</a></dt>
  661. <dd><p>Renames <code class="xref py py-func docutils literal notranslate"><span class="pre">xrange()</span></code> to <a class="reference internal" href="stdtypes.html#range" title="range"><code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code></a> and wraps existing <a class="reference internal" href="stdtypes.html#range" title="range"><code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code></a>
  662. calls with <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>.</p>
  663. </dd></dl>
  664. <dl class="std 2to3fixer">
  665. <dt class="sig sig-object std" id="to3fixer-xreadlines">
  666. <span class="sig-name descname"><span class="pre">xreadlines</span></span><a class="headerlink" href="#to3fixer-xreadlines" title="Link to this definition">¶</a></dt>
  667. <dd><p>Changes <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">file.xreadlines()</span></code> to <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">file</span></code>.</p>
  668. </dd></dl>
  669. <dl class="std 2to3fixer">
  670. <dt class="sig sig-object std" id="to3fixer-zip">
  671. <span class="sig-name descname"><span class="pre">zip</span></span><a class="headerlink" href="#to3fixer-zip" title="Link to this definition">¶</a></dt>
  672. <dd><p>Wraps <a class="reference internal" href="functions.html#zip" title="zip"><code class="xref py py-func docutils literal notranslate"><span class="pre">zip()</span></code></a> usage in a <a class="reference internal" href="stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> call. This is disabled when
  673. <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">future_builtins</span> <span class="pre">import</span> <span class="pre">zip</span></code> appears.</p>
  674. </dd></dl>
  675. </section>
  676. <section id="module-lib2to3">
  677. <span id="lib2to3-2to3-s-library"></span><h2><a class="reference internal" href="#module-lib2to3" title="lib2to3: The 2to3 library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code></a> — 2to3’s library<a class="headerlink" href="#module-lib2to3" title="Link to this heading">¶</a></h2>
  678. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/lib2to3/">Lib/lib2to3/</a></p>
  679. <hr class="docutils" />
  680. <div class="deprecated-removed">
  681. <p><span class="versionmodified">Deprecated since version 3.11, will be removed in version 3.13: </span>Python 3.9 switched to a PEG parser (see <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0617/"><strong>PEP 617</strong></a>) while lib2to3 is
  682. using a less flexible LL(1) parser. Python 3.10 includes new language
  683. syntax that is not parsable by lib2to3’s LL(1) parser (see <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0634/"><strong>PEP 634</strong></a>).
  684. The <code class="docutils literal notranslate"><span class="pre">lib2to3</span></code> module was marked pending for deprecation in Python 3.9
  685. (raising <a class="reference internal" href="exceptions.html#PendingDeprecationWarning" title="PendingDeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PendingDeprecationWarning</span></code></a> on import) and fully deprecated
  686. in Python 3.11 (raising <a class="reference internal" href="exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>).
  687. It will be removed from the standard library in Python 3.13.
  688. Consider third-party alternatives such as <a class="reference external" href="https://libcst.readthedocs.io/">LibCST</a> or <a class="reference external" href="https://parso.readthedocs.io/">parso</a>.</p>
  689. </div>
  690. <div class="admonition note">
  691. <p class="admonition-title">Note</p>
  692. <p>The <a class="reference internal" href="#module-lib2to3" title="lib2to3: The 2to3 library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code></a> API should be considered unstable and may change
  693. drastically in the future.</p>
  694. </div>
  695. </section>
  696. </section>
  697. <div class="clearer"></div>
  698. </div>
  699. </div>
  700. </div>
  701. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  702. <div class="sphinxsidebarwrapper">
  703. <div>
  704. <h3><a href="../contents.html">Table of Contents</a></h3>
  705. <ul>
  706. <li><a class="reference internal" href="#">2to3 — Automated Python 2 to 3 code translation</a><ul>
  707. <li><a class="reference internal" href="#using-2to3">Using 2to3</a></li>
  708. <li><a class="reference internal" href="#fixers">Fixers</a></li>
  709. <li><a class="reference internal" href="#module-lib2to3"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lib2to3</span></code> — 2to3’s library</a></li>
  710. </ul>
  711. </li>
  712. </ul>
  713. </div>
  714. <div>
  715. <h4>Previous topic</h4>
  716. <p class="topless"><a href="unittest.mock-examples.html"
  717. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">unittest.mock</span></code> — getting started</a></p>
  718. </div>
  719. <div>
  720. <h4>Next topic</h4>
  721. <p class="topless"><a href="test.html"
  722. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">test</span></code> — Regression tests package for Python</a></p>
  723. </div>
  724. <div role="note" aria-label="source link">
  725. <h3>This Page</h3>
  726. <ul class="this-page-menu">
  727. <li><a href="../bugs.html">Report a Bug</a></li>
  728. <li>
  729. <a href="https://github.com/python/cpython/blob/main/Doc/library/2to3.rst"
  730. rel="nofollow">Show Source
  731. </a>
  732. </li>
  733. </ul>
  734. </div>
  735. </div>
  736. <div id="sidebarbutton" title="Collapse sidebar">
  737. <span>«</span>
  738. </div>
  739. </div>
  740. <div class="clearer"></div>
  741. </div>
  742. <div class="related" role="navigation" aria-label="related navigation">
  743. <h3>Navigation</h3>
  744. <ul>
  745. <li class="right" style="margin-right: 10px">
  746. <a href="../genindex.html" title="General Index"
  747. >index</a></li>
  748. <li class="right" >
  749. <a href="../py-modindex.html" title="Python Module Index"
  750. >modules</a> |</li>
  751. <li class="right" >
  752. <a href="test.html" title="test — Regression tests package for Python"
  753. >next</a> |</li>
  754. <li class="right" >
  755. <a href="unittest.mock-examples.html" title="unittest.mock — getting started"
  756. >previous</a> |</li>
  757. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  758. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  759. <li class="switchers">
  760. <div class="language_switcher_placeholder"></div>
  761. <div class="version_switcher_placeholder"></div>
  762. </li>
  763. <li>
  764. </li>
  765. <li id="cpython-language-and-version">
  766. <a href="../index.html">3.12.3 Documentation</a> &#187;
  767. </li>
  768. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  769. <li class="nav-item nav-item-2"><a href="development.html" >Development Tools</a> &#187;</li>
  770. <li class="nav-item nav-item-this"><a href="">2to3 — Automated Python 2 to 3 code translation</a></li>
  771. <li class="right">
  772. <div class="inline-search" role="search">
  773. <form class="inline-search" action="../search.html" method="get">
  774. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  775. <input type="submit" value="Go" />
  776. </form>
  777. </div>
  778. |
  779. </li>
  780. <li class="right">
  781. <label class="theme-selector-label">
  782. Theme
  783. <select class="theme-selector" oninput="activateTheme(this.value)">
  784. <option value="auto" selected>Auto</option>
  785. <option value="light">Light</option>
  786. <option value="dark">Dark</option>
  787. </select>
  788. </label> |</li>
  789. </ul>
  790. </div>
  791. <div class="footer">
  792. &copy;
  793. <a href="../copyright.html">
  794. Copyright
  795. </a>
  796. 2001-2024, Python Software Foundation.
  797. <br />
  798. This page is licensed under the Python Software Foundation License Version 2.
  799. <br />
  800. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  801. <br />
  802. See <a href="/license.html">History and License</a> for more information.<br />
  803. <br />
  804. The Python Software Foundation is a non-profit corporation.
  805. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  806. <br />
  807. <br />
  808. Last updated on Apr 09, 2024 (13:47 UTC).
  809. <a href="/bugs.html">Found a bug</a>?
  810. <br />
  811. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  812. </div>
  813. </body>
  814. </html>
上海开阖软件有限公司 沪ICP备12045867号-1