Skip to content

Commit a90ad04

Browse files
committed
Add documentation
1 parent 970032b commit a90ad04

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

Doc/library/code.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ build applications which provide an interactive interpreter prompt.
4040
.. versionchanged:: 3.13
4141
Added *local_exit* parameter.
4242

43-
.. function:: interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=False)
43+
.. function:: interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=False, *, use_pyrepl=False)
4444

4545
Convenience function to run a read-eval-print loop. This creates a new
4646
instance of :class:`InteractiveConsole` and sets *readfunc* to be used as
@@ -49,15 +49,19 @@ build applications which provide an interactive interpreter prompt.
4949
use as the default namespace for the interpreter loop. If *local_exit* is provided,
5050
it is passed to the :class:`InteractiveConsole` constructor. The :meth:`~InteractiveConsole.interact`
5151
method of the instance is then run with *banner* and *exitmsg* passed as the
52-
banner and exit message to use, if provided. The console object is discarded
53-
after use.
52+
banner and exit message to use, if provided. The *use_pyrepl* argument is
53+
passed to :meth:`~InteractiveConsole.interact` to control whether to use the
54+
pyrepl-based REPL. The console object is discarded after use.
5455

5556
.. versionchanged:: 3.6
5657
Added *exitmsg* parameter.
5758

5859
.. versionchanged:: 3.13
5960
Added *local_exit* parameter.
6061

62+
.. versionchanged:: next
63+
Added *use_pyrepl* parameter.
64+
6165
.. function:: compile_command(source, filename="<input>", symbol="single")
6266

6367
This function is useful for programs that want to emulate Python's interpreter
@@ -153,7 +157,7 @@ The :class:`InteractiveConsole` class is a subclass of
153157
interpreter objects as well as the following additions.
154158

155159

156-
.. method:: InteractiveConsole.interact(banner=None, exitmsg=None)
160+
.. method:: InteractiveConsole.interact(banner=None, exitmsg=None, *, use_pyrepl=False)
157161

158162
Closely emulate the interactive Python console. The optional *banner* argument
159163
specify the banner to print before the first interaction; by default it prints a
@@ -165,12 +169,21 @@ interpreter objects as well as the following additions.
165169
Pass the empty string to suppress the exit message. If *exitmsg* is not given or
166170
``None``, a default message is printed.
167171

172+
The optional *use_pyrepl* argument controls whether to use the pyrepl-based REPL
173+
when available. When ``True``, pyrepl is used. When ``False`` (the default),
174+
the basic readline-based REPL is used. When ``None``, pyrepl is used
175+
automatically if available and the :envvar:`PYTHON_BASIC_REPL` environment
176+
variable is not set.
177+
168178
.. versionchanged:: 3.4
169179
To suppress printing any banner, pass an empty string.
170180

171181
.. versionchanged:: 3.6
172182
Print an exit message when exiting.
173183

184+
.. versionchanged:: next
185+
Added *use_pyrepl* parameter.
186+
174187

175188
.. method:: InteractiveConsole.push(line)
176189

0 commit comments

Comments
 (0)