File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -352,8 +352,9 @@ are always available. They are listed here in alphabetical order.
352352 The *mode * argument specifies what kind of code must be compiled; it can be
353353 ``'exec' `` if *source * consists of a sequence of statements, ``'eval' `` if it
354354 consists of a single expression, or ``'single' `` if it consists of a single
355- interactive statement (in the latter case, expression statements that
356- evaluate to something other than ``None `` will be printed).
355+ interactive statement. When the resulting code object is executed,
356+ expression statements that evaluate to something other than ``None `` are
357+ displayed using :func: `sys.displayhook `.
357358 It can also be ``'func_type' `` if *source * consists of a
358359 function type signature, for example ``(int) -> str ``; see
359360 :func: `ast.parse ` for more information. This mode requires passing
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ The ``code`` module provides facilities to implement read-eval-print loops in
1212Python. Two classes and convenience functions are included which can be used to
1313build applications which provide an interactive interpreter prompt.
1414
15+ When code compiled in ``'single' `` mode is executed, expression results other
16+ than ``None `` are displayed using :func: `sys.displayhook `, which writes to
17+ :data: `sys.stdout ` by default. Syntax errors and tracebacks are displayed using
18+ :meth: `InteractiveInterpreter.write `, which writes to :data: `sys.stderr ` by
19+ default. If :func: `sys.excepthook ` has been overridden, it is used to display
20+ syntax errors and tracebacks instead. The console's banner and exit message are
21+ also written using :meth: `InteractiveInterpreter.write `.
22+
1523
1624.. class :: InteractiveInterpreter(locals=None)
1725
You can’t perform that action at this time.
0 commit comments