[Tutor] Best version for novice

eryksun eryksun at gmail.com
Sun Feb 2 06:41:55 CET 2014


On Sat, Feb 1, 2014 at 8:20 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>
> I'm afraid that I have no idea what you are talking about here, Python
> doesn't accept a -n argument:

-n is an IDLE option:

    If IDLE is started with the -n command line switch it will run in a
    single process and will not create the subprocess which runs the RPC
    Python execution server.  This can be useful if Python cannot create
    the subprocess or the RPC socket interface on your platform.  However,
    in this mode user code is not isolated from IDLE itself.  Also, the
    environment is not restarted when Run/Run Module (F5) is selected.  If
    your code has been modified, you must reload() the affected modules and
    re-import any specific items (e.g. from foo import baz) if the changes
    are to take effect.  For these reasons, it is preferable to run IDLE
    with the default subprocess if at all possible.

With respect to Tkinter, using -n allows your widgets to piggyback on
IDLE's main loop. I looked into this a bit:

In a terminal you usually don't have to manually `update` [1] the
embedded Tcl interpreter's event queue. What happens is the _tkinter
extension module sets the global function pointer PyOS_InputHook to a
function that calls Tcl_DoOneEvent [2]. The readline module calls this
hook about 10 times per second while waiting for input. However,
readline isn't used for IDLE's child process, which gets code from a
socket in a background thread.

[1] http://www.tcl.tk/man/tcl8.5/TclCmd/update.htm
[2] http://www.tcl.tk/man/tcl8.5/TclLib/DoOneEvent.htm


More information about the Tutor mailing list