You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code execution process. A connection must be established whenever the Shell
634
633
starts or restarts. (The latter is indicated by a divider line that says
635
634
‘RESTART’). If the user process fails to connect to the GUI process, it
636
-
displays a <codeclass="docutils literal notranslate"><spanclass="pre">Tk</span></code> error box with a ‘cannot connect’ message that directs the
637
-
user here. It then exits.</p>
635
+
usually displays a <codeclass="docutils literal notranslate"><spanclass="pre">Tk</span></code> error box with a ‘cannot connect’ message
636
+
that directs the user here. It then exits.</p>
637
+
<p>One specific connection failure on Unix systems results from
638
+
misconfigured masquerading rules somewhere in a system’s network setup.
639
+
When IDLE is started from a terminal, one will see a message starting
640
+
with <codeclass="docutils literal notranslate"><spanclass="pre">**</span><spanclass="pre">Invalid</span><spanclass="pre">host:</span></code>.
641
+
The valid value is <codeclass="docutils literal notranslate"><spanclass="pre">127.0.0.1</span><spanclass="pre">(idlelib.rpc.LOCALHOST)</span></code>.
642
+
One can diagnose with <codeclass="docutils literal notranslate"><spanclass="pre">tcpconnect</span><spanclass="pre">-irv</span><spanclass="pre">127.0.0.1</span><spanclass="pre">6543</span></code> in one
643
+
terminal window and <codeclass="docutils literal notranslate"><spanclass="pre">tcplisten</span><spanclass="pre"><same</span><spanclass="pre">args></span></code> in another.</p>
638
644
<p>A common cause of failure is a user-written file with the same name as a
639
645
standard library module, such as <em>random.py</em> and <em>tkinter.py</em>. When such a
640
646
file is located in the same directory as a file that is about to be run,
<p>If IDLE quits with no message, and it was not started from a console, try
666
672
starting it from a console or terminal (<codeclass="docutils literal notranslate"><spanclass="pre">python</span><spanclass="pre">-m</span><spanclass="pre">idlelib</span></code>) and see if
667
673
this results in an error message.</p>
674
+
<p>On Unix-based systems with tcl/tk older than <codeclass="docutils literal notranslate"><spanclass="pre">8.6.11</span></code> (see
675
+
<codeclass="docutils literal notranslate"><spanclass="pre">About</span><spanclass="pre">IDLE</span></code>) certain characters of certain fonts can cause
676
+
a tk failure with a message to the terminal. This can happen either
677
+
if one starts IDLE to edit a file with such a character or later
678
+
when entering such a character. If one cannot upgrade tcl/tk,
679
+
then re-configure IDLE to use a font that works better.</p>
668
680
</div>
669
681
<divclass="section" id="running-user-code">
670
682
<h3>Running user code<aclass="headerlink" href="#running-user-code" title="Permalink to this headline">¶</a></h3>
@@ -680,24 +692,33 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm
680
692
with objects that get input from and send output to the Shell window.
681
693
The original values stored in <codeclass="docutils literal notranslate"><spanclass="pre">sys.__stdin__</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">sys.__stdout__</span></code>, and
682
694
<codeclass="docutils literal notranslate"><spanclass="pre">sys.__stderr__</span></code> are not touched, but may be <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>.</p>
683
-
<p>When Shell has the focus, it controls the keyboard and screen. This is
684
-
normally transparent, but functions that directly access the keyboard
685
-
and screen will not work. These include system-specific functions that
686
-
determine whether a key has been pressed and if so, which.</p>
695
+
<p>Sending print output from one process to a text widget in another is
696
+
slower than printing to a system terminal in the same process.
697
+
This has the most effect when printing multiple arguments, as the string
698
+
for each argument, each separator, the newline are sent separately.
699
+
For development, this is usually not a problem, but if one wants to
700
+
print faster in IDLE, format and join together everything one wants
701
+
displayed together and then print a single string. Both format strings
702
+
and <aclass="reference internal" href="stdtypes.html#str.join" title="str.join"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">str.join()</span></code></a> can help combine fields and lines.</p>
687
703
<p>IDLE’s standard stream replacements are not inherited by subprocesses
688
-
created in the execution process, whether directly by user code or by modules
689
-
such as multiprocessing. If such subprocess use <codeclass="docutils literal notranslate"><spanclass="pre">input</span></code> from sys.stdin
690
-
or <codeclass="docutils literal notranslate"><spanclass="pre">print</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> to sys.stdout or sys.stderr,
704
+
created in the execution process, whether directly by user code or by
705
+
modules such as multiprocessing. If such subprocess use <codeclass="docutils literal notranslate"><spanclass="pre">input</span></code> from
706
+
sys.stdin or <codeclass="docutils literal notranslate"><spanclass="pre">print</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> to sys.stdout or sys.stderr,
691
707
IDLE should be started in a command line window. The secondary subprocess
692
708
will then be attached to that window for input and output.</p>
693
-
<p>The IDLE code running in the execution process adds frames to the call stack
694
-
that would not be there otherwise. IDLE wraps <codeclass="docutils literal notranslate"><spanclass="pre">sys.getrecursionlimit</span></code> and
695
-
<codeclass="docutils literal notranslate"><spanclass="pre">sys.setrecursionlimit</span></code> to reduce the effect of the additional stack frames.</p>
696
709
<p>If <codeclass="docutils literal notranslate"><spanclass="pre">sys</span></code> is reset by user code, such as with <codeclass="docutils literal notranslate"><spanclass="pre">importlib.reload(sys)</span></code>,
697
710
IDLE’s changes are lost and input from the keyboard and output to the screen
698
711
will not work correctly.</p>
699
-
<p>When user code raises SystemExit either directly or by calling sys.exit, IDLE
700
-
returns to a Shell prompt instead of exiting.</p>
712
+
<p>When Shell has the focus, it controls the keyboard and screen. This is
713
+
normally transparent, but functions that directly access the keyboard
714
+
and screen will not work. These include system-specific functions that
715
+
determine whether a key has been pressed and if so, which.</p>
716
+
<p>The IDLE code running in the execution process adds frames to the call stack
717
+
that would not be there otherwise. IDLE wraps <codeclass="docutils literal notranslate"><spanclass="pre">sys.getrecursionlimit</span></code> and
718
+
<codeclass="docutils literal notranslate"><spanclass="pre">sys.setrecursionlimit</span></code> to reduce the effect of the additional stack
719
+
frames.</p>
720
+
<p>When user code raises SystemExit either directly or by calling sys.exit,
721
+
IDLE returns to a Shell prompt instead of exiting.</p>
701
722
</div>
702
723
<divclass="section" id="user-output-in-shell">
703
724
<h3>User output in Shell<aclass="headerlink" href="#user-output-in-shell" title="Permalink to this headline">¶</a></h3>
0 commit comments