[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(...)
    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 
effectively
give you a new empty shell environment if you have lots of imported 
modules.

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 
itself.
In that case restart is probably the best bet - or switch to the safer 
import X
style.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list