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
<p>If IDLE quits with no message, and it was not started from a console, try
617
617
starting from a console (<codeclass="docutils literal notranslate"><spanclass="pre">python</span><spanclass="pre">-m</span><spanclass="pre">idlelib)</span></code> and see if a message appears.</p>
<h3>IDLE-console differences<aclass="headerlink" href="#idle-console-differences" title="Permalink to this headline">¶</a></h3>
619
+
<divclass="section" id="running-user-code">
620
+
<h3>Running user code<aclass="headerlink" href="#running-user-code" title="Permalink to this headline">¶</a></h3>
621
621
<p>With rare exceptions, the result of executing Python code with IDLE is
622
-
intended to be the same as executing the same code in a console window.
622
+
intended to be the same as executing the same code by the default method,
623
+
directly with Python in a text-mode system console or terminal window.
623
624
However, the different interface and operation occasionally affect
624
-
visible results. For instance, <codeclass="docutils literal notranslate"><spanclass="pre">sys.modules</span></code> starts with more entries.</p>
625
-
<p>IDLE also replaces <codeclass="docutils literal notranslate"><spanclass="pre">sys.stdin</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">sys.stdout</span></code>, and <codeclass="docutils literal notranslate"><spanclass="pre">sys.stderr</span></code> with
626
-
objects that get input from and send output to the Shell window.
627
-
When Shell has the focus, it controls the keyboard and screen. This is
625
+
visible results. For instance, <codeclass="docutils literal notranslate"><spanclass="pre">sys.modules</span></code> starts with more entries,
626
+
and <codeclass="docutils literal notranslate"><spanclass="pre">threading.activeCount()</span></code> returns 2 instead of 1.</p>
627
+
<p>By default, IDLE runs user code in a separate OS process rather than in
628
+
the user interface process that runs the shell and editor. In the execution
629
+
process, it replaces <codeclass="docutils literal notranslate"><spanclass="pre">sys.stdin</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">sys.stdout</span></code>, and <codeclass="docutils literal notranslate"><spanclass="pre">sys.stderr</span></code>
630
+
with objects that get input from and send output to the Shell window.
631
+
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
632
+
<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>
633
+
<p>When Shell has the focus, it controls the keyboard and screen. This is
628
634
normally transparent, but functions that directly access the keyboard
629
-
and screen will not work. If <codeclass="docutils literal notranslate"><spanclass="pre">sys</span></code> is reset with <codeclass="docutils literal notranslate"><spanclass="pre">importlib.reload(sys)</span></code>,
630
-
IDLE’s changes are lost and things like <codeclass="docutils literal notranslate"><spanclass="pre">input</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">raw_input</span></code>, and
631
-
<codeclass="docutils literal notranslate"><spanclass="pre">print</span></code> will not work correctly.</p>
632
-
<p>With IDLE’s Shell, one enters, edits, and recalls complete statements.
633
-
Some consoles only work with a single physical line at a time. IDLE uses
634
-
<codeclass="docutils literal notranslate"><spanclass="pre">exec</span></code> to run each statement. As a result, <codeclass="docutils literal notranslate"><spanclass="pre">'__builtins__'</span></code> is always
635
-
defined for each statement.</p>
635
+
and screen will not work. These include system-specific functions that
636
+
determine whether a key has been pressed and if so, which.</p>
637
+
<p>IDLE’s standard stream replacements are not inherited by subprocesses
638
+
created in the execution process, whether directly by user code or by modules
639
+
such as multiprocessing. If such subprocess use <codeclass="docutils literal notranslate"><spanclass="pre">input</span></code> from sys.stdin
640
+
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,
641
+
IDLE should be started in a command line window. The secondary subprocess
642
+
will then be attached to that window for input and output.</p>
643
+
<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>,
644
+
IDLE’s changes are lost and input from the keyboard and output to the screen
0 commit comments