Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Doc/builtins/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ are always available. They are listed here in alphabetical order.
The *mode* argument specifies what kind of code must be compiled; it can be
``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if it
consists of a single expression, or ``'single'`` if it consists of a single
interactive statement (in the latter case, expression statements that
evaluate to something other than ``None`` will be printed).
interactive statement. When the resulting code object is executed,
expression statements that evaluate to something other than ``None`` are
displayed using :func:`sys.displayhook`.
It can also be ``'func_type'`` if *source* consists of a
function type signature, for example ``(int) -> str``; see
:func:`ast.parse` for more information. This mode requires passing
Expand Down
8 changes: 8 additions & 0 deletions Doc/library/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ The ``code`` module provides facilities to implement read-eval-print loops in
Python. Two classes and convenience functions are included which can be used to
build applications which provide an interactive interpreter prompt.

When code compiled in ``'single'`` mode is executed, expression results other
than ``None`` are displayed using :func:`sys.displayhook`, which writes to
:data:`sys.stdout` by default. Syntax errors and tracebacks are displayed using
:meth:`InteractiveInterpreter.write`, which writes to :data:`sys.stderr` by
default. If :func:`sys.excepthook` has been overridden, it is used to display
syntax errors and tracebacks instead. The console's banner and exit message are
also written using :meth:`InteractiveInterpreter.write`.


.. class:: InteractiveInterpreter(locals=None)

Expand Down
Loading