Reloading after from adder import * ????

Fredrik Lundh fredrik at pythonware.com
Sun Nov 19 18:00:07 CET 2006


Seymour wrote:

 > I just made some typos and was wondering if there was an easier
> way to clear the Python namespace at the interactive prompt rather than
> shutting Komodo down and restarting (really brute force).

most IDE's have a "reset interactive mode" command (it's ctrl-F6 in 
IDLE, for example).

another approach is to put the code in a script file, and run that file. 
  scripts always run in a clean namespace.

yet another approach is to stop using wildcard import ("from import *"). 
  if you refer to the things in Adder via the Adder namespace, you can 
just do

     reload(Adder)

to fetch the new version.

("from import *" is generally considered a "only use if you know what 
you're doing" construct in Python, so if it causes trouble for you, you 
shouldn't have used it in the first place, per definition ;-)

</F>




More information about the Python-list mailing list