gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

703 lines
53KB

  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="readline — GNU readline interface" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/readline.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="The readline module defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter. This module can be used directly, or via the rlcompleter..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="The readline module defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter. This module can be used directly, or via the rlcompleter..." />
  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>readline — GNU readline interface &#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="rlcompleter — Completion function for GNU readline" href="rlcompleter.html" />
  33. <link rel="prev" title="stringprep — Internet String Preparation" href="stringprep.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/readline.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="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code> — GNU readline interface</a><ul>
  86. <li><a class="reference internal" href="#init-file">Init file</a></li>
  87. <li><a class="reference internal" href="#line-buffer">Line buffer</a></li>
  88. <li><a class="reference internal" href="#history-file">History file</a></li>
  89. <li><a class="reference internal" href="#history-list">History list</a></li>
  90. <li><a class="reference internal" href="#startup-hooks">Startup hooks</a></li>
  91. <li><a class="reference internal" href="#completion">Completion</a></li>
  92. <li><a class="reference internal" href="#example">Example</a></li>
  93. </ul>
  94. </li>
  95. </ul>
  96. </div>
  97. <div>
  98. <h4>Previous topic</h4>
  99. <p class="topless"><a href="stringprep.html"
  100. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringprep</span></code> — Internet String Preparation</a></p>
  101. </div>
  102. <div>
  103. <h4>Next topic</h4>
  104. <p class="topless"><a href="rlcompleter.html"
  105. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">rlcompleter</span></code> — Completion function for GNU readline</a></p>
  106. </div>
  107. <div role="note" aria-label="source link">
  108. <h3>This Page</h3>
  109. <ul class="this-page-menu">
  110. <li><a href="../bugs.html">Report a Bug</a></li>
  111. <li>
  112. <a href="https://github.com/python/cpython/blob/main/Doc/library/readline.rst"
  113. rel="nofollow">Show Source
  114. </a>
  115. </li>
  116. </ul>
  117. </div>
  118. </nav>
  119. </div>
  120. </div>
  121. <div class="related" role="navigation" aria-label="related navigation">
  122. <h3>Navigation</h3>
  123. <ul>
  124. <li class="right" style="margin-right: 10px">
  125. <a href="../genindex.html" title="General Index"
  126. accesskey="I">index</a></li>
  127. <li class="right" >
  128. <a href="../py-modindex.html" title="Python Module Index"
  129. >modules</a> |</li>
  130. <li class="right" >
  131. <a href="rlcompleter.html" title="rlcompleter — Completion function for GNU readline"
  132. accesskey="N">next</a> |</li>
  133. <li class="right" >
  134. <a href="stringprep.html" title="stringprep — Internet String Preparation"
  135. accesskey="P">previous</a> |</li>
  136. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  137. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  138. <li class="switchers">
  139. <div class="language_switcher_placeholder"></div>
  140. <div class="version_switcher_placeholder"></div>
  141. </li>
  142. <li>
  143. </li>
  144. <li id="cpython-language-and-version">
  145. <a href="../index.html">3.12.3 Documentation</a> &#187;
  146. </li>
  147. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  148. <li class="nav-item nav-item-2"><a href="text.html" accesskey="U">Text Processing Services</a> &#187;</li>
  149. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code> — GNU readline interface</a></li>
  150. <li class="right">
  151. <div class="inline-search" role="search">
  152. <form class="inline-search" action="../search.html" method="get">
  153. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  154. <input type="submit" value="Go" />
  155. </form>
  156. </div>
  157. |
  158. </li>
  159. <li class="right">
  160. <label class="theme-selector-label">
  161. Theme
  162. <select class="theme-selector" oninput="activateTheme(this.value)">
  163. <option value="auto" selected>Auto</option>
  164. <option value="light">Light</option>
  165. <option value="dark">Dark</option>
  166. </select>
  167. </label> |</li>
  168. </ul>
  169. </div>
  170. <div class="document">
  171. <div class="documentwrapper">
  172. <div class="bodywrapper">
  173. <div class="body" role="main">
  174. <section id="module-readline">
  175. <span id="readline-gnu-readline-interface"></span><h1><a class="reference internal" href="#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> — GNU readline interface<a class="headerlink" href="#module-readline" title="Link to this heading">¶</a></h1>
  176. <hr class="docutils" />
  177. <p>The <a class="reference internal" href="#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> module defines a number of functions to facilitate
  178. completion and reading/writing of history files from the Python interpreter.
  179. This module can be used directly, or via the <a class="reference internal" href="rlcompleter.html#module-rlcompleter" title="rlcompleter: Python identifier completion, suitable for the GNU readline library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">rlcompleter</span></code></a> module, which
  180. supports completion of Python identifiers at the interactive prompt. Settings
  181. made using this module affect the behaviour of both the interpreter’s
  182. interactive prompt and the prompts offered by the built-in <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>
  183. function.</p>
  184. <p>Readline keybindings may be configured via an initialization file, typically
  185. <code class="docutils literal notranslate"><span class="pre">.inputrc</span></code> in your home directory. See <a class="reference external" href="https://tiswww.cwru.edu/php/chet/readline/rluserman.html#Readline-Init-File">Readline Init File</a>
  186. in the GNU Readline manual for information about the format and
  187. allowable constructs of that file, and the capabilities of the
  188. Readline library in general.</p>
  189. <div class="admonition note">
  190. <p class="admonition-title">Note</p>
  191. <p>The underlying Readline library API may be implemented by
  192. the <code class="docutils literal notranslate"><span class="pre">libedit</span></code> library instead of GNU readline.
  193. On macOS the <a class="reference internal" href="#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> module detects which library is being used
  194. at run time.</p>
  195. <p>The configuration file for <code class="docutils literal notranslate"><span class="pre">libedit</span></code> is different from that
  196. of GNU readline. If you programmatically load configuration strings
  197. you can check for the text “libedit” in <code class="xref py py-const docutils literal notranslate"><span class="pre">readline.__doc__</span></code>
  198. to differentiate between GNU readline and libedit.</p>
  199. <p>If you use <em>editline</em>/<code class="docutils literal notranslate"><span class="pre">libedit</span></code> readline emulation on macOS, the
  200. initialization file located in your home directory is named
  201. <code class="docutils literal notranslate"><span class="pre">.editrc</span></code>. For example, the following content in <code class="docutils literal notranslate"><span class="pre">~/.editrc</span></code> will
  202. turn ON <em>vi</em> keybindings and TAB completion:</p>
  203. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span><span class="p">:</span><span class="n">bind</span> <span class="o">-</span><span class="n">v</span>
  204. <span class="n">python</span><span class="p">:</span><span class="n">bind</span> <span class="o">^</span><span class="n">I</span> <span class="n">rl_complete</span>
  205. </pre></div>
  206. </div>
  207. </div>
  208. <section id="init-file">
  209. <h2>Init file<a class="headerlink" href="#init-file" title="Link to this heading">¶</a></h2>
  210. <p>The following functions relate to the init file and user configuration:</p>
  211. <dl class="py function">
  212. <dt class="sig sig-object py" id="readline.parse_and_bind">
  213. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">parse_and_bind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.parse_and_bind" title="Link to this definition">¶</a></dt>
  214. <dd><p>Execute the init line provided in the <em>string</em> argument. This calls
  215. <code class="xref c c-func docutils literal notranslate"><span class="pre">rl_parse_and_bind()</span></code> in the underlying library.</p>
  216. </dd></dl>
  217. <dl class="py function">
  218. <dt class="sig sig-object py" id="readline.read_init_file">
  219. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">read_init_file</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.read_init_file" title="Link to this definition">¶</a></dt>
  220. <dd><p>Execute a readline initialization file. The default filename is the last filename
  221. used. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">rl_read_init_file()</span></code> in the underlying library.</p>
  222. </dd></dl>
  223. </section>
  224. <section id="line-buffer">
  225. <h2>Line buffer<a class="headerlink" href="#line-buffer" title="Link to this heading">¶</a></h2>
  226. <p>The following functions operate on the line buffer:</p>
  227. <dl class="py function">
  228. <dt class="sig sig-object py" id="readline.get_line_buffer">
  229. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_line_buffer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_line_buffer" title="Link to this definition">¶</a></dt>
  230. <dd><p>Return the current contents of the line buffer (<code class="xref c c-data docutils literal notranslate"><span class="pre">rl_line_buffer</span></code>
  231. in the underlying library).</p>
  232. </dd></dl>
  233. <dl class="py function">
  234. <dt class="sig sig-object py" id="readline.insert_text">
  235. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">insert_text</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.insert_text" title="Link to this definition">¶</a></dt>
  236. <dd><p>Insert text into the line buffer at the cursor position. This calls
  237. <code class="xref c c-func docutils literal notranslate"><span class="pre">rl_insert_text()</span></code> in the underlying library, but ignores
  238. the return value.</p>
  239. </dd></dl>
  240. <dl class="py function">
  241. <dt class="sig sig-object py" id="readline.redisplay">
  242. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">redisplay</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.redisplay" title="Link to this definition">¶</a></dt>
  243. <dd><p>Change what’s displayed on the screen to reflect the current contents of the
  244. line buffer. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">rl_redisplay()</span></code> in the underlying library.</p>
  245. </dd></dl>
  246. </section>
  247. <section id="history-file">
  248. <h2>History file<a class="headerlink" href="#history-file" title="Link to this heading">¶</a></h2>
  249. <p>The following functions operate on a history file:</p>
  250. <dl class="py function">
  251. <dt class="sig sig-object py" id="readline.read_history_file">
  252. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">read_history_file</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.read_history_file" title="Link to this definition">¶</a></dt>
  253. <dd><p>Load a readline history file, and append it to the history list.
  254. The default filename is <code class="file docutils literal notranslate"><span class="pre">~/.history</span></code>. This calls
  255. <code class="xref c c-func docutils literal notranslate"><span class="pre">read_history()</span></code> in the underlying library.</p>
  256. </dd></dl>
  257. <dl class="py function">
  258. <dt class="sig sig-object py" id="readline.write_history_file">
  259. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">write_history_file</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.write_history_file" title="Link to this definition">¶</a></dt>
  260. <dd><p>Save the history list to a readline history file, overwriting any
  261. existing file. The default filename is <code class="file docutils literal notranslate"><span class="pre">~/.history</span></code>. This calls
  262. <code class="xref c c-func docutils literal notranslate"><span class="pre">write_history()</span></code> in the underlying library.</p>
  263. </dd></dl>
  264. <dl class="py function">
  265. <dt class="sig sig-object py" id="readline.append_history_file">
  266. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">append_history_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nelements</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.append_history_file" title="Link to this definition">¶</a></dt>
  267. <dd><p>Append the last <em>nelements</em> items of history to a file. The default filename is
  268. <code class="file docutils literal notranslate"><span class="pre">~/.history</span></code>. The file must already exist. This calls
  269. <code class="xref c c-func docutils literal notranslate"><span class="pre">append_history()</span></code> in the underlying library. This function
  270. only exists if Python was compiled for a version of the library
  271. that supports it.</p>
  272. <div class="versionadded">
  273. <p><span class="versionmodified added">New in version 3.5.</span></p>
  274. </div>
  275. </dd></dl>
  276. <dl class="py function">
  277. <dt class="sig sig-object py" id="readline.get_history_length">
  278. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_history_length</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_history_length" title="Link to this definition">¶</a></dt>
  279. <dt class="sig sig-object py" id="readline.set_history_length">
  280. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_history_length</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">length</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_history_length" title="Link to this definition">¶</a></dt>
  281. <dd><p>Set or return the desired number of lines to save in the history file.
  282. The <a class="reference internal" href="#readline.write_history_file" title="readline.write_history_file"><code class="xref py py-func docutils literal notranslate"><span class="pre">write_history_file()</span></code></a> function uses this value to truncate
  283. the history file, by calling <code class="xref c c-func docutils literal notranslate"><span class="pre">history_truncate_file()</span></code> in
  284. the underlying library. Negative values imply
  285. unlimited history file size.</p>
  286. </dd></dl>
  287. </section>
  288. <section id="history-list">
  289. <h2>History list<a class="headerlink" href="#history-list" title="Link to this heading">¶</a></h2>
  290. <p>The following functions operate on a global history list:</p>
  291. <dl class="py function">
  292. <dt class="sig sig-object py" id="readline.clear_history">
  293. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">clear_history</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.clear_history" title="Link to this definition">¶</a></dt>
  294. <dd><p>Clear the current history. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">clear_history()</span></code> in the
  295. underlying library. The Python function only exists if Python was
  296. compiled for a version of the library that supports it.</p>
  297. </dd></dl>
  298. <dl class="py function">
  299. <dt class="sig sig-object py" id="readline.get_current_history_length">
  300. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_current_history_length</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_current_history_length" title="Link to this definition">¶</a></dt>
  301. <dd><p>Return the number of items currently in the history. (This is different from
  302. <a class="reference internal" href="#readline.get_history_length" title="readline.get_history_length"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_history_length()</span></code></a>, which returns the maximum number of lines that will
  303. be written to a history file.)</p>
  304. </dd></dl>
  305. <dl class="py function">
  306. <dt class="sig sig-object py" id="readline.get_history_item">
  307. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_history_item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_history_item" title="Link to this definition">¶</a></dt>
  308. <dd><p>Return the current contents of history item at <em>index</em>. The item index
  309. is one-based. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">history_get()</span></code> in the underlying library.</p>
  310. </dd></dl>
  311. <dl class="py function">
  312. <dt class="sig sig-object py" id="readline.remove_history_item">
  313. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">remove_history_item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pos</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.remove_history_item" title="Link to this definition">¶</a></dt>
  314. <dd><p>Remove history item specified by its position from the history.
  315. The position is zero-based. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">remove_history()</span></code> in
  316. the underlying library.</p>
  317. </dd></dl>
  318. <dl class="py function">
  319. <dt class="sig sig-object py" id="readline.replace_history_item">
  320. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">replace_history_item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pos</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.replace_history_item" title="Link to this definition">¶</a></dt>
  321. <dd><p>Replace history item specified by its position with <em>line</em>.
  322. The position is zero-based. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">replace_history_entry()</span></code>
  323. in the underlying library.</p>
  324. </dd></dl>
  325. <dl class="py function">
  326. <dt class="sig sig-object py" id="readline.add_history">
  327. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">add_history</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.add_history" title="Link to this definition">¶</a></dt>
  328. <dd><p>Append <em>line</em> to the history buffer, as if it was the last line typed.
  329. This calls <code class="xref c c-func docutils literal notranslate"><span class="pre">add_history()</span></code> in the underlying library.</p>
  330. </dd></dl>
  331. <dl class="py function">
  332. <dt class="sig sig-object py" id="readline.set_auto_history">
  333. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_auto_history</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">enabled</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_auto_history" title="Link to this definition">¶</a></dt>
  334. <dd><p>Enable or disable automatic calls to <code class="xref c c-func docutils literal notranslate"><span class="pre">add_history()</span></code> when reading
  335. input via readline. The <em>enabled</em> argument should be a Boolean value
  336. that when true, enables auto history, and that when false, disables
  337. auto history.</p>
  338. <div class="versionadded">
  339. <p><span class="versionmodified added">New in version 3.6.</span></p>
  340. </div>
  341. <div class="impl-detail compound">
  342. <p><strong>CPython implementation detail:</strong> Auto history is enabled by default, and changes to this do not persist
  343. across multiple sessions.</p>
  344. </div>
  345. </dd></dl>
  346. </section>
  347. <section id="startup-hooks">
  348. <h2>Startup hooks<a class="headerlink" href="#startup-hooks" title="Link to this heading">¶</a></h2>
  349. <dl class="py function">
  350. <dt class="sig sig-object py" id="readline.set_startup_hook">
  351. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_startup_hook</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_startup_hook" title="Link to this definition">¶</a></dt>
  352. <dd><p>Set or remove the function invoked by the <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_startup_hook</span></code>
  353. callback of the underlying library. If <em>function</em> is specified, it will
  354. be used as the new hook function; if omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, any function
  355. already installed is removed. The hook is called with no
  356. arguments just before readline prints the first prompt.</p>
  357. </dd></dl>
  358. <dl class="py function">
  359. <dt class="sig sig-object py" id="readline.set_pre_input_hook">
  360. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_pre_input_hook</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_pre_input_hook" title="Link to this definition">¶</a></dt>
  361. <dd><p>Set or remove the function invoked by the <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_pre_input_hook</span></code>
  362. callback of the underlying library. If <em>function</em> is specified, it will
  363. be used as the new hook function; if omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, any
  364. function already installed is removed. The hook is called
  365. with no arguments after the first prompt has been printed and just before
  366. readline starts reading input characters. This function only exists
  367. if Python was compiled for a version of the library that supports it.</p>
  368. </dd></dl>
  369. </section>
  370. <section id="completion">
  371. <span id="readline-completion"></span><h2>Completion<a class="headerlink" href="#completion" title="Link to this heading">¶</a></h2>
  372. <p>The following functions relate to implementing a custom word completion
  373. function. This is typically operated by the Tab key, and can suggest and
  374. automatically complete a word being typed. By default, Readline is set up
  375. to be used by <a class="reference internal" href="rlcompleter.html#module-rlcompleter" title="rlcompleter: Python identifier completion, suitable for the GNU readline library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">rlcompleter</span></code></a> to complete Python identifiers for
  376. the interactive interpreter. If the <a class="reference internal" href="#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> module is to be used
  377. with a custom completer, a different set of word delimiters should be set.</p>
  378. <dl class="py function">
  379. <dt class="sig sig-object py" id="readline.set_completer">
  380. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_completer</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_completer" title="Link to this definition">¶</a></dt>
  381. <dd><p>Set or remove the completer function. If <em>function</em> is specified, it will be
  382. used as the new completer function; if omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, any completer
  383. function already installed is removed. The completer function is called as
  384. <code class="docutils literal notranslate"><span class="pre">function(text,</span> <span class="pre">state)</span></code>, for <em>state</em> in <code class="docutils literal notranslate"><span class="pre">0</span></code>, <code class="docutils literal notranslate"><span class="pre">1</span></code>, <code class="docutils literal notranslate"><span class="pre">2</span></code>, …, until it
  385. returns a non-string value. It should return the next possible completion
  386. starting with <em>text</em>.</p>
  387. <p>The installed completer function is invoked by the <em>entry_func</em> callback
  388. passed to <code class="xref c c-func docutils literal notranslate"><span class="pre">rl_completion_matches()</span></code> in the underlying library.
  389. The <em>text</em> string comes from the first parameter to the
  390. <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_attempted_completion_function</span></code> callback of the
  391. underlying library.</p>
  392. </dd></dl>
  393. <dl class="py function">
  394. <dt class="sig sig-object py" id="readline.get_completer">
  395. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_completer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_completer" title="Link to this definition">¶</a></dt>
  396. <dd><p>Get the completer function, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if no completer function has been set.</p>
  397. </dd></dl>
  398. <dl class="py function">
  399. <dt class="sig sig-object py" id="readline.get_completion_type">
  400. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_completion_type</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_completion_type" title="Link to this definition">¶</a></dt>
  401. <dd><p>Get the type of completion being attempted. This returns the
  402. <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_completion_type</span></code> variable in the underlying library as
  403. an integer.</p>
  404. </dd></dl>
  405. <dl class="py function">
  406. <dt class="sig sig-object py" id="readline.get_begidx">
  407. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_begidx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_begidx" title="Link to this definition">¶</a></dt>
  408. <dt class="sig sig-object py" id="readline.get_endidx">
  409. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_endidx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_endidx" title="Link to this definition">¶</a></dt>
  410. <dd><p>Get the beginning or ending index of the completion scope.
  411. These indexes are the <em>start</em> and <em>end</em> arguments passed to the
  412. <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_attempted_completion_function</span></code> callback of the
  413. underlying library. The values may be different in the same
  414. input editing scenario based on the underlying C readline implementation.
  415. Ex: libedit is known to behave differently than libreadline.</p>
  416. </dd></dl>
  417. <dl class="py function">
  418. <dt class="sig sig-object py" id="readline.set_completer_delims">
  419. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_completer_delims</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_completer_delims" title="Link to this definition">¶</a></dt>
  420. <dt class="sig sig-object py" id="readline.get_completer_delims">
  421. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">get_completer_delims</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.get_completer_delims" title="Link to this definition">¶</a></dt>
  422. <dd><p>Set or get the word delimiters for completion. These determine the
  423. start of the word to be considered for completion (the completion scope).
  424. These functions access the <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_completer_word_break_characters</span></code>
  425. variable in the underlying library.</p>
  426. </dd></dl>
  427. <dl class="py function">
  428. <dt class="sig sig-object py" id="readline.set_completion_display_matches_hook">
  429. <span class="sig-prename descclassname"><span class="pre">readline.</span></span><span class="sig-name descname"><span class="pre">set_completion_display_matches_hook</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#readline.set_completion_display_matches_hook" title="Link to this definition">¶</a></dt>
  430. <dd><p>Set or remove the completion display function. If <em>function</em> is
  431. specified, it will be used as the new completion display function;
  432. if omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, any completion display function already
  433. installed is removed. This sets or clears the
  434. <code class="xref c c-data docutils literal notranslate"><span class="pre">rl_completion_display_matches_hook</span></code> callback in the
  435. underlying library. The completion display function is called as
  436. <code class="docutils literal notranslate"><span class="pre">function(substitution,</span> <span class="pre">[matches],</span> <span class="pre">longest_match_length)</span></code> once
  437. each time matches need to be displayed.</p>
  438. </dd></dl>
  439. </section>
  440. <section id="example">
  441. <span id="readline-example"></span><h2>Example<a class="headerlink" href="#example" title="Link to this heading">¶</a></h2>
  442. <p>The following example demonstrates how to use the <a class="reference internal" href="#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> module’s
  443. history reading and writing functions to automatically load and save a history
  444. file named <code class="file docutils literal notranslate"><span class="pre">.python_history</span></code> from the user’s home directory. The code
  445. below would normally be executed automatically during interactive sessions
  446. from the user’s <span class="target" id="index-0"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code></a> file.</p>
  447. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">atexit</span>
  448. <span class="kn">import</span> <span class="nn">os</span>
  449. <span class="kn">import</span> <span class="nn">readline</span>
  450. <span class="n">histfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~&quot;</span><span class="p">),</span> <span class="s2">&quot;.python_history&quot;</span><span class="p">)</span>
  451. <span class="k">try</span><span class="p">:</span>
  452. <span class="n">readline</span><span class="o">.</span><span class="n">read_history_file</span><span class="p">(</span><span class="n">histfile</span><span class="p">)</span>
  453. <span class="c1"># default history len is -1 (infinite), which may grow unruly</span>
  454. <span class="n">readline</span><span class="o">.</span><span class="n">set_history_length</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
  455. <span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
  456. <span class="k">pass</span>
  457. <span class="n">atexit</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">readline</span><span class="o">.</span><span class="n">write_history_file</span><span class="p">,</span> <span class="n">histfile</span><span class="p">)</span>
  458. </pre></div>
  459. </div>
  460. <p>This code is actually automatically run when Python is run in
  461. <a class="reference internal" href="../tutorial/interpreter.html#tut-interactive"><span class="std std-ref">interactive mode</span></a> (see <a class="reference internal" href="site.html#rlcompleter-config"><span class="std std-ref">Readline configuration</span></a>).</p>
  462. <p>The following example achieves the same goal but supports concurrent interactive
  463. sessions, by only appending the new history.</p>
  464. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">atexit</span>
  465. <span class="kn">import</span> <span class="nn">os</span>
  466. <span class="kn">import</span> <span class="nn">readline</span>
  467. <span class="n">histfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~&quot;</span><span class="p">),</span> <span class="s2">&quot;.python_history&quot;</span><span class="p">)</span>
  468. <span class="k">try</span><span class="p">:</span>
  469. <span class="n">readline</span><span class="o">.</span><span class="n">read_history_file</span><span class="p">(</span><span class="n">histfile</span><span class="p">)</span>
  470. <span class="n">h_len</span> <span class="o">=</span> <span class="n">readline</span><span class="o">.</span><span class="n">get_current_history_length</span><span class="p">()</span>
  471. <span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
  472. <span class="nb">open</span><span class="p">(</span><span class="n">histfile</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
  473. <span class="n">h_len</span> <span class="o">=</span> <span class="mi">0</span>
  474. <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="n">prev_h_len</span><span class="p">,</span> <span class="n">histfile</span><span class="p">):</span>
  475. <span class="n">new_h_len</span> <span class="o">=</span> <span class="n">readline</span><span class="o">.</span><span class="n">get_current_history_length</span><span class="p">()</span>
  476. <span class="n">readline</span><span class="o">.</span><span class="n">set_history_length</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
  477. <span class="n">readline</span><span class="o">.</span><span class="n">append_history_file</span><span class="p">(</span><span class="n">new_h_len</span> <span class="o">-</span> <span class="n">prev_h_len</span><span class="p">,</span> <span class="n">histfile</span><span class="p">)</span>
  478. <span class="n">atexit</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">save</span><span class="p">,</span> <span class="n">h_len</span><span class="p">,</span> <span class="n">histfile</span><span class="p">)</span>
  479. </pre></div>
  480. </div>
  481. <p>The following example extends the <a class="reference internal" href="code.html#code.InteractiveConsole" title="code.InteractiveConsole"><code class="xref py py-class docutils literal notranslate"><span class="pre">code.InteractiveConsole</span></code></a> class to
  482. support history save/restore.</p>
  483. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">atexit</span>
  484. <span class="kn">import</span> <span class="nn">code</span>
  485. <span class="kn">import</span> <span class="nn">os</span>
  486. <span class="kn">import</span> <span class="nn">readline</span>
  487. <span class="k">class</span> <span class="nc">HistoryConsole</span><span class="p">(</span><span class="n">code</span><span class="o">.</span><span class="n">InteractiveConsole</span><span class="p">):</span>
  488. <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">locals</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s2">&quot;&lt;console&gt;&quot;</span><span class="p">,</span>
  489. <span class="n">histfile</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~/.console-history&quot;</span><span class="p">)):</span>
  490. <span class="n">code</span><span class="o">.</span><span class="n">InteractiveConsole</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">locals</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span>
  491. <span class="bp">self</span><span class="o">.</span><span class="n">init_history</span><span class="p">(</span><span class="n">histfile</span><span class="p">)</span>
  492. <span class="k">def</span> <span class="nf">init_history</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">histfile</span><span class="p">):</span>
  493. <span class="n">readline</span><span class="o">.</span><span class="n">parse_and_bind</span><span class="p">(</span><span class="s2">&quot;tab: complete&quot;</span><span class="p">)</span>
  494. <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">readline</span><span class="p">,</span> <span class="s2">&quot;read_history_file&quot;</span><span class="p">):</span>
  495. <span class="k">try</span><span class="p">:</span>
  496. <span class="n">readline</span><span class="o">.</span><span class="n">read_history_file</span><span class="p">(</span><span class="n">histfile</span><span class="p">)</span>
  497. <span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
  498. <span class="k">pass</span>
  499. <span class="n">atexit</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">save_history</span><span class="p">,</span> <span class="n">histfile</span><span class="p">)</span>
  500. <span class="k">def</span> <span class="nf">save_history</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">histfile</span><span class="p">):</span>
  501. <span class="n">readline</span><span class="o">.</span><span class="n">set_history_length</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
  502. <span class="n">readline</span><span class="o">.</span><span class="n">write_history_file</span><span class="p">(</span><span class="n">histfile</span><span class="p">)</span>
  503. </pre></div>
  504. </div>
  505. </section>
  506. </section>
  507. <div class="clearer"></div>
  508. </div>
  509. </div>
  510. </div>
  511. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  512. <div class="sphinxsidebarwrapper">
  513. <div>
  514. <h3><a href="../contents.html">Table of Contents</a></h3>
  515. <ul>
  516. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code> — GNU readline interface</a><ul>
  517. <li><a class="reference internal" href="#init-file">Init file</a></li>
  518. <li><a class="reference internal" href="#line-buffer">Line buffer</a></li>
  519. <li><a class="reference internal" href="#history-file">History file</a></li>
  520. <li><a class="reference internal" href="#history-list">History list</a></li>
  521. <li><a class="reference internal" href="#startup-hooks">Startup hooks</a></li>
  522. <li><a class="reference internal" href="#completion">Completion</a></li>
  523. <li><a class="reference internal" href="#example">Example</a></li>
  524. </ul>
  525. </li>
  526. </ul>
  527. </div>
  528. <div>
  529. <h4>Previous topic</h4>
  530. <p class="topless"><a href="stringprep.html"
  531. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringprep</span></code> — Internet String Preparation</a></p>
  532. </div>
  533. <div>
  534. <h4>Next topic</h4>
  535. <p class="topless"><a href="rlcompleter.html"
  536. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">rlcompleter</span></code> — Completion function for GNU readline</a></p>
  537. </div>
  538. <div role="note" aria-label="source link">
  539. <h3>This Page</h3>
  540. <ul class="this-page-menu">
  541. <li><a href="../bugs.html">Report a Bug</a></li>
  542. <li>
  543. <a href="https://github.com/python/cpython/blob/main/Doc/library/readline.rst"
  544. rel="nofollow">Show Source
  545. </a>
  546. </li>
  547. </ul>
  548. </div>
  549. </div>
  550. <div id="sidebarbutton" title="Collapse sidebar">
  551. <span>«</span>
  552. </div>
  553. </div>
  554. <div class="clearer"></div>
  555. </div>
  556. <div class="related" role="navigation" aria-label="related navigation">
  557. <h3>Navigation</h3>
  558. <ul>
  559. <li class="right" style="margin-right: 10px">
  560. <a href="../genindex.html" title="General Index"
  561. >index</a></li>
  562. <li class="right" >
  563. <a href="../py-modindex.html" title="Python Module Index"
  564. >modules</a> |</li>
  565. <li class="right" >
  566. <a href="rlcompleter.html" title="rlcompleter — Completion function for GNU readline"
  567. >next</a> |</li>
  568. <li class="right" >
  569. <a href="stringprep.html" title="stringprep — Internet String Preparation"
  570. >previous</a> |</li>
  571. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  572. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  573. <li class="switchers">
  574. <div class="language_switcher_placeholder"></div>
  575. <div class="version_switcher_placeholder"></div>
  576. </li>
  577. <li>
  578. </li>
  579. <li id="cpython-language-and-version">
  580. <a href="../index.html">3.12.3 Documentation</a> &#187;
  581. </li>
  582. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  583. <li class="nav-item nav-item-2"><a href="text.html" >Text Processing Services</a> &#187;</li>
  584. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code> — GNU readline interface</a></li>
  585. <li class="right">
  586. <div class="inline-search" role="search">
  587. <form class="inline-search" action="../search.html" method="get">
  588. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  589. <input type="submit" value="Go" />
  590. </form>
  591. </div>
  592. |
  593. </li>
  594. <li class="right">
  595. <label class="theme-selector-label">
  596. Theme
  597. <select class="theme-selector" oninput="activateTheme(this.value)">
  598. <option value="auto" selected>Auto</option>
  599. <option value="light">Light</option>
  600. <option value="dark">Dark</option>
  601. </select>
  602. </label> |</li>
  603. </ul>
  604. </div>
  605. <div class="footer">
  606. &copy;
  607. <a href="../copyright.html">
  608. Copyright
  609. </a>
  610. 2001-2024, Python Software Foundation.
  611. <br />
  612. This page is licensed under the Python Software Foundation License Version 2.
  613. <br />
  614. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  615. <br />
  616. See <a href="/license.html">History and License</a> for more information.<br />
  617. <br />
  618. The Python Software Foundation is a non-profit corporation.
  619. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  620. <br />
  621. <br />
  622. Last updated on Apr 09, 2024 (13:47 UTC).
  623. <a href="/bugs.html">Found a bug</a>?
  624. <br />
  625. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  626. </div>
  627. </body>
  628. </html>
上海开阖软件有限公司 沪ICP备12045867号-1