Skip to content

Commit 75d9d59

Browse files
authored
bpo-23220: Explain how IDLE's Shell displays output (pythonGH-10356)
Add a new subsection to the doc.
1 parent 5ed6995 commit 75d9d59

File tree

3 files changed

+91
-23
lines changed

3 files changed

+91
-23
lines changed

Doc/library/idle.rst

+48-12
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,16 @@ or immediately run an existing file before editing.
502502
Python Shell window
503503
^^^^^^^^^^^^^^^^^^^
504504

505-
The editing features described above work when entering code interactively.
506-
IDLE's Shell window also responds to the following keys.
505+
With IDLE's Shell, one enters, edits, and recalls complete statements.
506+
Most consoles and terminals only work with a single physical line at a time.
507+
508+
When one pastes code into Shell, it is not compiled and possibly executed
509+
until one hits :kbd:`Return`. One may edit pasted code first.
510+
If one pastes more that one statement into Shell, the result will be a
511+
:exc:`SyntaxError` when multiple statements are compiled as if they were one.
512+
513+
The editing features described in previous subsections work when entering
514+
code interactively. IDLE's Shell window also responds to the following keys.
507515

508516
* :kbd:`C-c` interrupts executing command
509517

@@ -520,16 +528,6 @@ IDLE's Shell window also responds to the following keys.
520528

521529
* :kbd:`Return` while on any previous command retrieves that command
522530

523-
Shell has a special facility for squeezing output lines down to a
524-
'Squeezed text' label. This is done automatically for output over N lines
525-
(N = 50 by default). N can be changed in the PyShell section of the General
526-
page of the Settings dialog. Output with fewer lines can be squeezed by
527-
right clicking on the output. This can be useful for extra long lines.
528-
529-
Squeezed output is expanded in place by double-clicking the label.
530-
It can also be sent to the clipboard or a separate view window by
531-
right-clicking the label.
532-
533531
Text colors
534532
^^^^^^^^^^^
535533

@@ -666,6 +664,44 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
666664
IDLE's changes are lost and input from the keyboard and output to the screen
667665
will not work correctly.
668666

667+
User output in Shell
668+
^^^^^^^^^^^^^^^^^^^^
669+
670+
When a program outputs text, the result is determined by the
671+
corresponding output device. When IDLE executes user code, ``sys.stdout``
672+
and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of
673+
its features are inherited from the underlying Tk Text widget. Others
674+
are programmed additions.
675+
676+
Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
677+
Which characters get a proper glyph instead of a replacement box depends on
678+
the operating system and installed fonts. Newline characters cause following
679+
text to appear on a new line, but other control characters are replaced
680+
with a box. But note that the ``repr()`` function, which is used for
681+
interactive echo of expression values, replaces control characters
682+
with escape codes before they are output.
683+
684+
Normal and error output are generally kept separate (on separate lines)
685+
from code input and each other. They each get different highlight colors.
686+
687+
For SyntaxError tracebacks, the normal '^' marking where the error was
688+
detected is replaced by coloring the text with an error highlight.
689+
When code run from a file causes other exceptions, one may right click
690+
on a traceback line to jump to the corresponding line in an IDLE editor.
691+
The file will be opened if necessary.
692+
693+
Shell has a special facility for squeezing output lines down to a
694+
'Squeezed text' label. This is done automatically
695+
for output over N lines (N = 50 by default).
696+
N can be changed in the PyShell section of the General
697+
page of the Settings dialog. Output with fewer lines can be squeezed by
698+
right clicking on the output. This can be useful lines long enough to slow
699+
down scrolling.
700+
701+
Squeezed output is expanded in place by double-clicking the label.
702+
It can also be sent to the clipboard or a separate view window by
703+
right-clicking the label.
704+
669705
Developing tkinter applications
670706
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
671707

Lib/idlelib/help.html

+42-11
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,14 @@ <h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this head
501501
</div>
502502
<div class="section" id="python-shell-window">
503503
<h3>Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline"></a></h3>
504-
<p>The editing features described above work when entering code interactively.
505-
IDLE’s Shell window also responds to the following keys.</p>
504+
<p>With IDLE’s Shell, one enters, edits, and recalls complete statements.
505+
Most consoles and terminals only work with a single physical line at a time.</p>
506+
<p>When one pastes code into Shell, it is not compiled and possibly executed
507+
until one hits <kbd class="kbd docutils literal notranslate">Return</kbd>. One may edit pasted code first.
508+
If one pastes more that one statement into Shell, the result will be a
509+
<a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a> when multiple statements are compiled as if they were one.</p>
510+
<p>The editing features described in previous subsections work when entering
511+
code interactively. IDLE’s Shell window also responds to the following keys.</p>
506512
<ul>
507513
<li><p class="first"><kbd class="kbd docutils literal notranslate">C-c</kbd> interrupts executing command</p>
508514
</li>
@@ -518,14 +524,6 @@ <h3>Python Shell window<a class="headerlink" href="#python-shell-window" title="
518524
</ul>
519525
</li>
520526
</ul>
521-
<p>Shell has a special facility for squeezing output lines down to a
522-
‘Squeezed text’ label. This is done automatically for output over N lines
523-
(N = 50 by default). N can be changed in the PyShell section of the General
524-
page of the Settings dialog. Output with fewer lines can be squeezed by
525-
right clicking on the output. This can be useful for extra long lines.</p>
526-
<p>Squeezed output is expanded in place by double-clicking the label.
527-
It can also be sent to the clipboard or a separate view window by
528-
right-clicking the label.</p>
529527
</div>
530528
<div class="section" id="text-colors">
531529
<h3>Text colors<a class="headerlink" href="#text-colors" title="Permalink to this headline"></a></h3>
@@ -644,6 +642,38 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm
644642
IDLE’s changes are lost and input from the keyboard and output to the screen
645643
will not work correctly.</p>
646644
</div>
645+
<div class="section" id="user-output-in-shell">
646+
<h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Permalink to this headline"></a></h3>
647+
<p>When a program outputs text, the result is determined by the
648+
corresponding output device. When IDLE executes user code, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>
649+
and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> are connected to the display area of IDLE’s Shell. Some of
650+
its features are inherited from the underlying Tk Text widget. Others
651+
are programmed additions.</p>
652+
<p>Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
653+
Which characters get a proper glyph instead of a replacement box depends on
654+
the operating system and installed fonts. Newline characters cause following
655+
text to appear on a new line, but other control characters are replaced
656+
with a box. But note that the <code class="docutils literal notranslate"><span class="pre">repr()</span></code> function, which is used for
657+
interactive echo of expression values, replaces control characters
658+
with escape codes before they are output.</p>
659+
<p>Normal and error output are generally kept separate (on separate lines)
660+
from code input and each other. They each get different highlight colors.</p>
661+
<p>For SyntaxError tracebacks, the normal ‘^’ marking where the error was
662+
detected is replaced by coloring the text with an error highlight.
663+
When code run from a file causes other exceptions, one may right click
664+
on a traceback line to jump to the corresponding line in an IDLE editor.
665+
The file will be opened if necessary.</p>
666+
<p>Shell has a special facility for squeezing output lines down to a
667+
‘Squeezed text’ label. This is done automatically
668+
for output over N lines (N = 50 by default).
669+
N can be changed in the PyShell section of the General
670+
page of the Settings dialog. Output with fewer lines can be squeezed by
671+
right clicking on the output. This can be useful lines long enough to slow
672+
down scrolling.</p>
673+
<p>Squeezed output is expanded in place by double-clicking the label.
674+
It can also be sent to the clipboard or a separate view window by
675+
right-clicking the label.</p>
676+
</div>
647677
<div class="section" id="developing-tkinter-applications">
648678
<h3>Developing tkinter applications<a class="headerlink" href="#developing-tkinter-applications" title="Permalink to this headline"></a></h3>
649679
<p>IDLE is intentionally different from standard Python in order to
@@ -763,6 +793,7 @@ <h3><a href="../contents.html">Table of Contents</a></h3>
763793
<li><a class="reference internal" href="#command-line-usage">Command line usage</a></li>
764794
<li><a class="reference internal" href="#startup-failure">Startup failure</a></li>
765795
<li><a class="reference internal" href="#running-user-code">Running user code</a></li>
796+
<li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li>
766797
<li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li>
767798
<li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li>
768799
</ul>
@@ -851,7 +882,7 @@ <h3>Navigation</h3>
851882
<br />
852883
<br />
853884

854-
Last updated on Nov 05, 2018.
885+
Last updated on Nov 06, 2018.
855886
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
856887
<br />
857888

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Explain how IDLE's Shell displays output.

0 commit comments

Comments
 (0)