1.. _tut-interacting:
2
3**************************************************
4Interactive Input Editing and History Substitution
5**************************************************
6
7Some versions of the Python interpreter support editing of the current input
8line and history substitution, similar to facilities found in the Korn shell and
9the GNU Bash shell.  This is implemented using the `GNU Readline`_ library,
10which supports various styles of editing.  This library has its own
11documentation which we won't duplicate here.
12
13
14.. _tut-keybindings:
15
16Tab Completion and History Editing
17==================================
18
19Completion of variable and module names is
20:ref:`automatically enabled <rlcompleter-config>` at interpreter startup so
21that the :kbd:`Tab` key invokes the completion function; it looks at
22Python statement names, the current local variables, and the available
23module names.  For dotted expressions such as ``string.a``, it will evaluate
24the expression up to the final ``'.'`` and then suggest completions from
25the attributes of the resulting object.  Note that this may execute
26application-defined code if an object with a :meth:`__getattr__` method
27is part of the expression.  The default configuration also saves your
28history into a file named :file:`.python_history` in your user directory.
29The history will be available again during the next interactive interpreter
30session.
31
32
33.. _tut-commentary:
34
35Alternatives to the Interactive Interpreter
36===========================================
37
38This facility is an enormous step forward compared to earlier versions of the
39interpreter; however, some wishes are left: It would be nice if the proper
40indentation were suggested on continuation lines (the parser knows if an indent
41token is required next).  The completion mechanism might use the interpreter's
42symbol table.  A command to check (or even suggest) matching parentheses,
43quotes, etc., would also be useful.
44
45One alternative enhanced interactive interpreter that has been around for quite
46some time is IPython_, which features tab completion, object exploration and
47advanced history management.  It can also be thoroughly customized and embedded
48into other applications.  Another similar enhanced interactive environment is
49bpython_.
50
51
52.. _GNU Readline: https://tiswww.case.edu/php/chet/readline/rltop.html
53.. _IPython: https://ipython.org/
54.. _bpython: https://www.bpython-interpreter.org/
55