[Tutor] re-initialising shells

Alan Gauld alan.gauld at btinternet.com
Fri Dec 21 09:47:24 CET 2007

"Jim Morcombe" <jmorcombe at westnet.com.au> wrote

> I have changed qwerty and saved it away.
> I have then run my program (F5) and the program acts as
> if it is using an old version of qwerty.

You need to "reload" the module to pick up the changes.

>>> help(reload)
Help on built-in function reload in module __builtin__:

    reload(module) -> module

    Reload the module.  The module must have been successfully 
imported before.

In addition there is a Restart menu option in IDLE that will 
give you a new empty shell environment if you have lots of imported 

However I'm not sure if reload will work if you use the from X import 
approach since that imports all of the names rather than the module 
In that case restart is probably the best bet - or switch to the safer 
import X


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list