summaryrefslogtreecommitdiff
path: root/Doc/library/code.rst
diff options
context:
space:
mode:
authorMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
committerMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
commitda79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (patch)
tree74845e2dbd9521d9748b9c32f1922f4123083bf3 /Doc/library/code.rst
parente3c7e835bdfc97750eb9b7fc0ad2493108c2d438 (diff)
parent1fe806ac56f8b83694d24ab604eb695d00bc8497 (diff)
downloadcpython-da79bcf8ac7ae72218ab023e1ed54390bc1a3a27.tar.gz
Issue #29371: merge with 3.5
Diffstat (limited to 'Doc/library/code.rst')
-rw-r--r--Doc/library/code.rst19
1 files changed, 15 insertions, 4 deletions
diff --git a/Doc/library/code.rst b/Doc/library/code.rst
index 443af699f2..e2c47bab5a 100644
--- a/Doc/library/code.rst
+++ b/Doc/library/code.rst
@@ -30,15 +30,19 @@ build applications which provide an interactive interpreter prompt.
``sys.ps1`` and ``sys.ps2``, and input buffering.
-.. function:: interact(banner=None, readfunc=None, local=None)
+.. function:: interact(banner=None, readfunc=None, local=None, exitmsg=None)
Convenience function to run a read-eval-print loop. This creates a new
instance of :class:`InteractiveConsole` and sets *readfunc* to be used as
the :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is
provided, it is passed to the :class:`InteractiveConsole` constructor for
use as the default namespace for the interpreter loop. The :meth:`interact`
- method of the instance is then run with *banner* passed as the banner to
- use, if provided. The console object is discarded after use.
+ method of the instance is then run with *banner* and *exitmsg* passed as the
+ banner and exit message to use, if provided. The console object is discarded
+ after use.
+
+ .. versionchanged:: 3.6
+ Added *exitmsg* parameter.
.. function:: compile_command(source, filename="<input>", symbol="single")
@@ -136,7 +140,7 @@ The :class:`InteractiveConsole` class is a subclass of
interpreter objects as well as the following additions.
-.. method:: InteractiveConsole.interact(banner=None)
+.. method:: InteractiveConsole.interact(banner=None, exitmsg=None)
Closely emulate the interactive Python console. The optional *banner* argument
specify the banner to print before the first interaction; by default it prints a
@@ -144,9 +148,16 @@ interpreter objects as well as the following additions.
by the class name of the console object in parentheses (so as not to confuse
this with the real interpreter -- since it's so close!).
+ The optional *exitmsg* argument specifies an exit message printed when exiting.
+ Pass the empty string to suppress the exit message. If *exitmsg* is not given or
+ ``None``, a default message is printed.
+
.. versionchanged:: 3.4
To suppress printing any banner, pass an empty string.
+ .. versionchanged:: 3.6
+ Print an exit message when exiting.
+
.. method:: InteractiveConsole.push(line)