Kaydet (Commit) 929d7f86 authored tarafından Terry Jan Reedy's avatar Terry Jan Reedy

Clarify IDLE-console differences with respect to the sys module.

The reload(sys) effect was the crux of a Stackoverflow question.
üst ac962053
...@@ -550,14 +550,16 @@ IDLE-console differences ...@@ -550,14 +550,16 @@ IDLE-console differences
As much as possible, the result of executing Python code with IDLE is the As much as possible, the result of executing Python code with IDLE is the
same as executing the same code in a console window. However, the different same as executing the same code in a console window. However, the different
interface and operation occasionally affects results. interface and operation occasionally affects visible results. For instance,
``sys.modules`` starts with more entries.
For instance, IDLE normally executes user code in a separate process from
the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with
execution process get input from and send output to the GUI process, objects that get input from and send output to the Shell window.
which keeps control of the keyboard and screen. This is normally transparent, When this window has the focus, it controls the keyboard and screen.
but code that access these object will see different attribute values. This is normally transparent, but functions that directly access the keyboard
Also, functions that directly access the keyboard and screen will not work. and screen will not work. If ``sys`` is reset with ``importlib.reload(sys)``,
IDLE's changes are lost and things li ke ``input``, ``raw_input``, and
``print`` will not work correctly.
With IDLE's Shell, one enters, edits, and recalls complete statements. With IDLE's Shell, one enters, edits, and recalls complete statements.
Some consoles only work with a single physical line at a time. Some consoles only work with a single physical line at a time.
......
...@@ -163,7 +163,7 @@ be undone.</dd> ...@@ -163,7 +163,7 @@ be undone.</dd>
<dt>Find Selection</dt> <dt>Find Selection</dt>
<dd>Search for the currently selected string, if there is one.</dd> <dd>Search for the currently selected string, if there is one.</dd>
<dt>Find in Files...</dt> <dt>Find in Files...</dt>
<dd>Open a file search dialog. Put results in an new output window.</dd> <dd>Open a file search dialog. Put results in a new output window.</dd>
<dt>Replace...</dt> <dt>Replace...</dt>
<dd>Open a search-and-replace dialog.</dd> <dd>Open a search-and-replace dialog.</dd>
<dt>Go to Line</dt> <dt>Go to Line</dt>
...@@ -517,13 +517,15 @@ set in the Options dialog.</li> ...@@ -517,13 +517,15 @@ set in the Options dialog.</li>
<h3>25.5.3.2. IDLE-console differences<a class="headerlink" href="#idle-console-differences" title="Permalink to this headline"></a></h3> <h3>25.5.3.2. IDLE-console differences<a class="headerlink" href="#idle-console-differences" title="Permalink to this headline"></a></h3>
<p>As much as possible, the result of executing Python code with IDLE is the <p>As much as possible, the result of executing Python code with IDLE is the
same as executing the same code in a console window. However, the different same as executing the same code in a console window. However, the different
interface and operation occasionally affects results.</p> interface and operation occasionally affects visible results. For instance,
<p>For instance, IDLE normally executes user code in a separate process from <code class="docutils literal"><span class="pre">sys.modules</span></code> starts with more entries.</p>
the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the <p>IDLE also replaces <code class="docutils literal"><span class="pre">sys.stdin</span></code>, <code class="docutils literal"><span class="pre">sys.stdout</span></code>, and <code class="docutils literal"><span class="pre">sys.stderr</span></code> with
execution process get input from and send output to the GUI process, objects that get input from and send output to the Shell window.
which keeps control of the keyboard and screen. This is normally transparent, When this window has the focus, it controls the keyboard and screen.
but code that access these object will see different attribute values. This is normally transparent, but functions that directly access the keyboard
Also, functions that directly access the keyboard and screen will not work.</p> and screen will not work. If <code class="docutils literal"><span class="pre">sys</span></code> is reset with <code class="docutils literal"><span class="pre">importlib.reload(sys)</span></code>,
IDLE&#8217;s changes are lost and things li ke <code class="docutils literal"><span class="pre">input</span></code>, <code class="docutils literal"><span class="pre">raw_input</span></code>, and
<code class="docutils literal"><span class="pre">print</span></code> will not work correctly.</p>
<p>With IDLE&#8217;s Shell, one enters, edits, and recalls complete statements. <p>With IDLE&#8217;s Shell, one enters, edits, and recalls complete statements.
Some consoles only work with a single physical line at a time.</p> Some consoles only work with a single physical line at a time.</p>
</div> </div>
...@@ -694,12 +696,12 @@ are currently:</p> ...@@ -694,12 +696,12 @@ are currently:</p>
</ul> </ul>
</div> </div>
<div class="footer"> <div class="footer">
&copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation. &copy; <a href="../copyright.html">Copyright</a> 2001-2016, Python Software Foundation.
<br /> <br />
The Python Software Foundation is a non-profit corporation. The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a> <a href="https://www.python.org/psf/donations/">Please donate.</a>
<br /> <br />
Last updated on Feb 29, 2016. Last updated on May 02, 2016.
<a href="../bugs.html">Found a bug</a>? <a href="../bugs.html">Found a bug</a>?
<br /> <br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment