summaryrefslogtreecommitdiffstats
path: root/Doc/library/readline.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-05-04 18:08:35 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-05-04 18:08:35 (GMT)
commit1a6cb30a346ba8812d6abc77fddee636ae06ccff (patch)
tree3ba3f519e8e29fd616365fec41803795ba406bf3 /Doc/library/readline.rst
parent4c14b5de1cf372e963a4378fc6cb2bca36d24eb8 (diff)
downloadcpython-1a6cb30a346ba8812d6abc77fddee636ae06ccff.zip
cpython-1a6cb30a346ba8812d6abc77fddee636ae06ccff.tar.gz
cpython-1a6cb30a346ba8812d6abc77fddee636ae06ccff.tar.bz2
Issue #5845: Enable tab-completion in the interactive interpreter by default, thanks to a new sys.__interactivehook__.
(original patch by Éric Araujo)
Diffstat (limited to 'Doc/library/readline.rst')
-rw-r--r--Doc/library/readline.rst20
1 files changed, 12 insertions, 8 deletions
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
index 1134619..692310b 100644
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -190,28 +190,32 @@ Example
The following example demonstrates how to use the :mod:`readline` module's
history reading and writing functions to automatically load and save a history
-file named :file:`.pyhist` from the user's home directory. The code below would
-normally be executed automatically during interactive sessions from the user's
-:envvar:`PYTHONSTARTUP` file. ::
+file named :file:`.python_history` from the user's home directory. The code
+below would normally be executed automatically during interactive sessions
+from the user's :envvar:`PYTHONSTARTUP` file. ::
+ import atexit
import os
import readline
- histfile = os.path.join(os.path.expanduser("~"), ".pyhist")
+
+ histfile = os.path.join(os.path.expanduser("~"), ".python_history")
try:
readline.read_history_file(histfile)
except FileNotFoundError:
pass
- import atexit
+
atexit.register(readline.write_history_file, histfile)
- del os, histfile
+
+This code is actually automatically run when Python is run in
+:ref:`interactive mode <tut-interactive>` (see :ref:`rlcompleter-config`).
The following example extends the :class:`code.InteractiveConsole` class to
support history save/restore. ::
- import code
- import readline
import atexit
+ import code
import os
+ import readline
class HistoryConsole(code.InteractiveConsole):
def __init__(self, locals=None, filename="<console>",