Skip to content

Commit 8a03ff2

Browse files
authored
bpo-35833: Revise IDLE doc for control codes sent to Shell. (pythonGH-11799)
Add a code example block.
1 parent 2dda72a commit 8a03ff2

File tree

4 files changed

+62
-22
lines changed

4 files changed

+62
-22
lines changed

Doc/library/idle.rst

+27-8
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,33 @@ In contrast, some system text windows only keep the last n lines of output.
716716
A Windows console, for instance, keeps a user-settable 1 to 9999 lines,
717717
with 300 the default.
718718

719-
Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
720-
Which characters get a proper glyph instead of a replacement box depends on
721-
the operating system and installed fonts. Newline characters cause following
722-
text to appear on a new line, but other control characters are either
723-
replaced with a box or deleted. However, ``repr()``, which is used for
724-
interactive echo of expression values, replaces control characters,
725-
some BMP codepoints, and all non-BMP characters with escape codes
726-
before they are output.
719+
A Tk Text widget, and hence IDLE's Shell, displays characters (codepoints)
720+
in the the BMP (Basic Multilingual Plane) subset of Unicode.
721+
Which characters are displayed with a proper glyph and which with a
722+
replacement box depends on the operating system and installed fonts.
723+
Tab characters cause the following text to begin after
724+
the next tab stop. (They occur every 8 'characters').
725+
Newline characters cause following text to appear on a new line.
726+
Other control characters are ignored or displayed as a space, box, or
727+
something else, depending on the operating system and font.
728+
(Moving the text cursor through such output with arrow keys may exhibit
729+
some surprising spacing behavior.)
730+
731+
.. code-block:: none
732+
733+
>>> s = 'a\tb\a<\x02><\r>\bc\nd'
734+
>>> len(s)
735+
14
736+
>>> s # Display repr(s)
737+
'a\tb\x07<\x02><\r>\x08c\nd'
738+
>>> print(s, end='') # Display s as is.
739+
# Result varies by OS and font. Try it.
740+
741+
The ``repr`` function is used for interactive echo of expression
742+
values. It returns an altered version of the input string in which
743+
control codes, some BMP codepoints, and all non-BMP codepoints are
744+
replaced with escape codes. As demonstrated above, it allows one to
745+
identify the characters in a string, regardless of how they are displayed.
727746

728747
Normal and error output are generally kept separate (on separate lines)
729748
from code input and each other. They each get different highlight colors.

Lib/idlelib/NEWS.txt

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Released on 2019-10-20?
33
======================================
44

55

6+
bpo-35833: Revise IDLE doc for control codes sent to Shell.
7+
Add a code example block.
8+
69
bpo-35770: IDLE macosx deletes Options => Configure IDLE.
710
It previously deleted Window => Zoom Height by mistake.
811
(Zoom Height is now on the Options menu). On Mac, the settings

Lib/idlelib/help.html

+31-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<head>
77
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
88
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9-
<title>IDLE &#8212; Python 3.8.0a0 documentation</title>
9+
<title>IDLE &#8212; Python 3.8.0a1 documentation</title>
1010
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
1111
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
1212

@@ -19,7 +19,7 @@
1919
<script type="text/javascript" src="../_static/sidebar.js"></script>
2020

2121
<link rel="search" type="application/opensearchdescription+xml"
22-
title="Search within Python 3.8.0a0 documentation"
22+
title="Search within Python 3.8.0a1 documentation"
2323
href="../_static/opensearch.xml"/>
2424
<link rel="author" title="About these documents" href="../about.html" />
2525
<link rel="index" title="Index" href="../genindex.html" />
@@ -72,7 +72,7 @@ <h3>Navigation</h3>
7272

7373

7474
<li>
75-
<a href="../index.html">3.8.0a0 Documentation</a> &#187;
75+
<a href="../index.html">3.8.0a1 Documentation</a> &#187;
7676
</li>
7777

7878
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
@@ -673,14 +673,31 @@ <h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title
673673
In contrast, some system text windows only keep the last n lines of output.
674674
A Windows console, for instance, keeps a user-settable 1 to 9999 lines,
675675
with 300 the default.</p>
676-
<p>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 either
680-
replaced with a box or deleted. However, <code class="docutils literal notranslate"><span class="pre">repr()</span></code>, which is used for
681-
interactive echo of expression values, replaces control characters,
682-
some BMP codepoints, and all non-BMP characters with escape codes
683-
before they are output.</p>
676+
<p>A Tk Text widget, and hence IDLE’s Shell, displays characters (codepoints)
677+
in the the BMP (Basic Multilingual Plane) subset of Unicode.
678+
Which characters are displayed with a proper glyph and which with a
679+
replacement box depends on the operating system and installed fonts.
680+
Tab characters cause the following text to begin after
681+
the next tab stop. (They occur every 8 ‘characters’).
682+
Newline characters cause following text to appear on a new line.
683+
Other control characters are ignored or displayed as a space, box, or
684+
something else, depending on the operating system and font.
685+
(Moving the text cursor through such output with arrow keys may exhibit
686+
some surprising spacing behavior.)</p>
687+
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt;&gt;&gt; s = &#39;a\tb\a&lt;\x02&gt;&lt;\r&gt;\bc\nd&#39;
688+
&gt;&gt;&gt; len(s)
689+
14
690+
&gt;&gt;&gt; s # Display repr(s)
691+
&#39;a\tb\x07&lt;\x02&gt;&lt;\r&gt;\x08c\nd&#39;
692+
&gt;&gt;&gt; print(s, end=&#39;&#39;) # Display s as is.
693+
# Result varies by OS and font. Try it.
694+
</pre></div>
695+
</div>
696+
<p>The <code class="docutils literal notranslate"><span class="pre">repr</span></code> function is used for interactive echo of expression
697+
values. It returns an altered version of the input string in which
698+
control codes, some BMP codepoints, and all non-BMP codepoints are
699+
replaced with escape codes. As demonstrated above, it allows one to
700+
identify the characters in a string, regardless of how they are displayed.</p>
684701
<p>Normal and error output are generally kept separate (on separate lines)
685702
from code input and each other. They each get different highlight colors.</p>
686703
<p>For SyntaxError tracebacks, the normal ‘^’ marking where the error was
@@ -889,7 +906,7 @@ <h3>Navigation</h3>
889906

890907

891908
<li>
892-
<a href="../index.html">3.8.0a0 Documentation</a> &#187;
909+
<a href="../index.html">3.8.0a1 Documentation</a> &#187;
893910
</li>
894911

895912
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
@@ -912,15 +929,15 @@ <h3>Navigation</h3>
912929
</ul>
913930
</div>
914931
<div class="footer">
915-
&copy; <a href="../copyright.html">Copyright</a> 2001-2018, Python Software Foundation.
932+
&copy; <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation.
916933
<br />
917934

918935
The Python Software Foundation is a non-profit corporation.
919936
<a href="https://www.python.org/psf/donations/">Please donate.</a>
920937
<br />
921938
<br />
922939

923-
Last updated on Dec 28, 2018.
940+
Last updated on Feb 08, 2019.
924941
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
925942
<br />
926943

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Revise IDLE doc for control codes sent to Shell. Add a code example block.

0 commit comments

Comments
 (0)