Reason for not allowing import twice but allowing reload()

Terry Reedy tjreedy at udel.edu
Tue Mar 1 02:04:35 EST 2016


On 2/29/2016 8:22 AM, alien2utoo at gmail.com wrote:
> Hello Rustom,
>
> F5 in Idle restarts the Python interpreter (that's what my impression is).

More exactly, IDLE runs user code in a separate process from the one 
that runs the IDLE gui.  Restarting means that the existing user process 
is terminated and a new one started.  This is easier than trying to 
'clean up' the existing process.

If you start python with '> python' in a terminal, then restarting the 
interactive interpreter means '>>> quit' at the interactive prompt 
followed by "> python" in the console.  You do the equivalent in IDLE 
Shell with 'control-F6' or 'Shell -> Restart Shell.

F5 when editing path/file.py replaces the command 'python' with 'cd 
path' followed by 'python -i file.py'

Maybe I should add something to the IDLE doc for people familiar with 
using python in a console.  (Most beginners are not.)

> Whatever you have done earlier at Idle prompt (in Idle session)
 > before F5 is gone after F5.

Yes, the same as if you quit().  A change I would like to make sometime 
is to have F5 run the file is a new user process without killing the old 
one, so one does not loose work done in Shell.

-- 
Terry Jan Reedy




More information about the Python-list mailing list