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