[Tutor] IDLE 1.2 Question

Luke Paireepinart rabidpoobear at gmail.com
Sun Aug 12 03:02:52 CEST 2007

Jerry VanBrimmer wrote:
> I'm using IDLE 1.2 with Python 2.5.
> My question is, when I'm coding something in an IDLE window, save the
> code as a file.py, then click on Run>Run Module; and then I change
> something in the code, resave the file, click on Run>Run Module again;
> does this remap the namespace in the Python shell? (While using the
> same shell.) It seems to me that sometimes it does and sometimes it
> doesn't. Can anybody clarify this, just how does IDLE handle the
> namespace mapping?
It depends whether IDLE is opened with a subprocess or not.  If it's a 
subprocess, your program will have a separate interpreter entirely from 
that used by IDLE, so the namespace will be the default namespace.
If IDLE doesn't have a subprocess, your program will be run in the same 
interpreter as IDLE itself is running in, and since IDLE doesn't end 
between runs of your program, all the variables you declare will hang 
You could test this if you want.  Do
import random
print random.randint(1,5)

then take out the import and run it again.  If the print statement still 
works, IDLE's not using a subprocess.
There have been many threads about this, it's usually a Windows issue.

More information about the Tutor mailing list