summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-05-05 19:32:23 (GMT)
committerGitHub <noreply@github.com>2024-05-05 19:32:23 (GMT)
commitf27f8c790af1233d499b795af1c0d1b36aaecaf5 (patch)
tree22c502c6382512fafbb63e3020c8462e5400d4df /Doc
parent40cc809902304f60c6e1c933191dd4d64e570e28 (diff)
downloadcpython-f27f8c790af1233d499b795af1c0d1b36aaecaf5.zip
cpython-f27f8c790af1233d499b795af1c0d1b36aaecaf5.tar.gz
cpython-f27f8c790af1233d499b795af1c0d1b36aaecaf5.tar.bz2
gh-111201: A new Python REPL (GH-111567)
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Marta Gómez Macías <mgmacias@google.com> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/glossary.rst14
-rw-r--r--Doc/tutorial/appendix.rst22
-rw-r--r--Doc/using/cmdline.rst10
-rw-r--r--Doc/whatsnew/3.13.rst28
4 files changed, 70 insertions, 4 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 05ac3ed..2846f77 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -9,13 +9,14 @@ Glossary
.. glossary::
``>>>``
- The default Python prompt of the interactive shell. Often seen for code
- examples which can be executed interactively in the interpreter.
+ The default Python prompt of the :term:`interactive` shell. Often
+ seen for code examples which can be executed interactively in the
+ interpreter.
``...``
Can refer to:
- * The default Python prompt of the interactive shell when entering the
+ * The default Python prompt of the :term:`interactive` shell when entering the
code for an indented code block, when within a pair of matching left and
right delimiters (parentheses, square brackets, curly braces or triple
quotes), or after specifying a decorator.
@@ -620,7 +621,8 @@ Glossary
execute them and see their results. Just launch ``python`` with no
arguments (possibly by selecting it from your computer's main
menu). It is a very powerful way to test out new ideas or inspect
- modules and packages (remember ``help(x)``).
+ modules and packages (remember ``help(x)``). For more on interactive
+ mode, see :ref:`tut-interac`.
interpreted
Python is an interpreted language, as opposed to a compiled one,
@@ -1084,6 +1086,10 @@ Glossary
See also :term:`namespace package`.
+ REPL
+ An acronym for the "read–eval–print loop", another name for the
+ :term:`interactive` interpreter shell.
+
__slots__
A declaration inside a class that saves memory by pre-declaring space for
instance attributes and eliminating instance dictionaries. Though
diff --git a/Doc/tutorial/appendix.rst b/Doc/tutorial/appendix.rst
index 4bea0d8..10eb143 100644
--- a/Doc/tutorial/appendix.rst
+++ b/Doc/tutorial/appendix.rst
@@ -10,6 +10,28 @@ Appendix
Interactive Mode
================
+There are two variants of the interactive :term:`REPL`. The classic
+basic interpreter is supported on all platforms with minimal line
+control capabilities.
+
+On Unix-like systems (e.g. Linux or macOS) with :mod:`curses` and
+:mod:`readline` support, a new interactive shell is used by default.
+This one supports color, multiline editing, history browsing, and
+paste mode. To disable color, see :ref:`using-on-controlling-color` for
+details. Function keys provide some additional functionality.
+:kbd:`F1` enters the interactive help browser :mod:`pydoc`.
+:kbd:`F2` allows for browsing command-line history without output nor the
+:term:`>>>` and :term:`...` prompts. :kbd:`F3` enters "paste mode", which
+makes pasting larger blocks of code easier. Press :kbd:`F3` to return to
+the regular prompt.
+
+When using the new interactive shell, exit the shell by typing :kbd:`exit`
+or :kbd:`quit`. Adding call parentheses after those commands is not
+required.
+
+If the new interactive shell is not desired, it can be disabled via
+the :envvar:`PYTHON_BASIC_REPL` environment variable.
+
.. _tut-error:
Error Handling
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index 051dbf9..522e6e5 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -42,6 +42,7 @@ additional methods of invocation:
* When called with standard input connected to a tty device, it prompts for
commands and executes them until an EOF (an end-of-file character, you can
produce that with :kbd:`Ctrl-D` on UNIX or :kbd:`Ctrl-Z, Enter` on Windows) is read.
+ For more on interactive mode, see :ref:`tut-interac`.
* When called with a file name argument or with a file as standard input, it
reads and executes a script from that file.
* When called with a directory name argument, it reads and executes an
@@ -1182,6 +1183,15 @@ conflict.
.. versionadded:: 3.13
+.. envvar:: PYTHON_BASIC_REPL
+
+ If this variable is set to ``1``, the interpreter will not attempt to
+ load the Python-based :term:`REPL` that requires :mod:`curses` and
+ :mod:`readline`, and will instead use the traditional parser-based
+ :term:`REPL`.
+
+ .. versionadded:: 3.13
+
.. envvar:: PYTHON_HISTORY
This environment variable can be used to set the location of a
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 152c870..11c3f93 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -102,6 +102,34 @@ New typing features:
New Features
============
+A Better Interactive Interpreter
+--------------------------------
+
+On Unix-like systems like Linux or macOS, Python now uses a new
+:term:`interactive` shell. When the user starts the :term:`REPL`
+from a tty, and both :mod:`curses` and :mod:`readline` are available,
+the interactive shell now supports the following new features:
+
+* colorized prompts;
+* multiline editing with history preservation;
+* interactive help browsing using :kbd:`F1` with a separate command
+ history;
+* history browsing using :kbd:`F2` that skips output as well as the
+ :term:`>>>` and :term:`...` prompts;
+* "paste mode" with :kbd:`F3` that makes pasting larger blocks of code
+ easier (press :kbd:`F3` again to return to the regular prompt);
+* ability to issue REPL-specific commands like :kbd:`help`, :kbd:`exit`,
+ and :kbd:`quit` without the need to use call parentheses after the
+ command name.
+
+If the new interactive shell is not desired, it can be disabled via
+the :envvar:`PYTHON_BASIC_REPL` environment variable.
+
+For more on interactive mode, see :ref:`tut-interac`.
+
+(Contributed by Pablo Galindo Salgado, Łukasz Langa, and
+Lysandros Nikolaou in :gh:`111201` based on code from the PyPy project.)
+
Improved Error Messages
-----------------------