@@ -563,7 +563,6 @@ looked for in the user's home directory. Statements in this file will be
563
563
executed in the Tk namespace, so this file is not useful for importing
564
564
functions to be used from IDLE's Python shell.
565
565
566
-
567
566
Command line usage
568
567
^^^^^^^^^^^^^^^^^^
569
568
@@ -591,7 +590,6 @@ If there are arguments:
591
590
* Otherwise, arguments are files opened for editing and
592
591
``sys.argv `` reflects the arguments passed to IDLE itself.
593
592
594
-
595
593
Startup failure
596
594
^^^^^^^^^^^^^^^
597
595
@@ -635,27 +633,38 @@ be to delete one or more of the configuration files.
635
633
If IDLE quits with no message, and it was not started from a console, try
636
634
starting from a console (``python -m idlelib) `` and see if a message appears.
637
635
638
-
639
- IDLE-console differences
640
- ^^^^^^^^^^^^^^^^^^^^^^^^
636
+ Running user code
637
+ ^^^^^^^^^^^^^^^^^
641
638
642
639
With rare exceptions, the result of executing Python code with IDLE is
643
- intended to be the same as executing the same code in a console window.
640
+ intended to be the same as executing the same code by the default method,
641
+ directly with Python in a text-mode system console or terminal window.
644
642
However, the different interface and operation occasionally affect
645
- visible results. For instance, ``sys.modules `` starts with more entries.
643
+ visible results. For instance, ``sys.modules `` starts with more entries,
644
+ and ``threading.activeCount() `` returns 2 instead of 1.
645
+
646
+ By default, IDLE runs user code in a separate OS process rather than in
647
+ the user interface process that runs the shell and editor. In the execution
648
+ process, it replaces ``sys.stdin ``, ``sys.stdout ``, and ``sys.stderr ``
649
+ with objects that get input from and send output to the Shell window.
650
+ The original values stored in ``sys.__stdin__ ``, ``sys.__stdout__ ``, and
651
+ ``sys.__stderr__ `` are not touched, but may be ``None ``.
646
652
647
- IDLE also replaces ``sys.stdin ``, ``sys.stdout ``, and ``sys.stderr `` with
648
- objects that get input from and send output to the Shell window.
649
653
When Shell has the focus, it controls the keyboard and screen. This is
650
654
normally transparent, but functions that directly access the keyboard
651
- and screen will not work. If ``sys `` is reset with ``importlib.reload(sys) ``,
652
- IDLE's changes are lost and things like ``input ``, ``raw_input ``, and
653
- ``print `` will not work correctly.
654
-
655
- With IDLE's Shell, one enters, edits, and recalls complete statements.
656
- Some consoles only work with a single physical line at a time. IDLE uses
657
- ``exec `` to run each statement. As a result, ``'__builtins__' `` is always
658
- defined for each statement.
655
+ and screen will not work. These include system-specific functions that
656
+ determine whether a key has been pressed and if so, which.
657
+
658
+ IDLE's standard stream replacements are not inherited by subprocesses
659
+ created in the execution process, whether directly by user code or by modules
660
+ such as multiprocessing. If such subprocess use ``input `` from sys.stdin
661
+ or ``print `` or ``write `` to sys.stdout or sys.stderr,
662
+ IDLE should be started in a command line window. The secondary subprocess
663
+ will then be attached to that window for input and output.
664
+
665
+ If ``sys `` is reset by user code, such as with ``importlib.reload(sys) ``,
666
+ IDLE's changes are lost and input from the keyboard and output to the screen
667
+ will not work correctly.
659
668
660
669
Developing tkinter applications
661
670
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments