[Tutor] Working interactively with IDE (refreshing script; namespace updating)
Sun, 05 Aug 2001 14:49:38 -0500
After reading the "Up All Night with IDLE" thread
and seeing the post by Patrick regarding "Refreshing a script"
I came up with the following way to work with IDE:
When you are working on a script in a window and you make
changes to an object (variable, function, etc...) name,
the old object still exists. This means that you will not
always get an "is not defined" error even though you would if
you quit and tried to run your script after restarting IDE.
print "y=",x ## <--forgot to change the 2nd x
# the modified program will print "y= 2" -- even
# though the x variable is undefined in the script it is
# still remembered by Python in this IDE window and
# that is what you told it (inadvertently) to print.
Work with two scripts, one to load your active work and one
containing your developing script:
# tester.py (this just loads and reloads your work)
# mywork.py (this is the one that will contain your work
When you make changes to "mywork.py" and *save* these changes and
then run the "tester.py" program as written, you work in "mywork"
will be reloaded and if you have a modification like shown above,
you will generate an error since x is not defined.
When your scipt runs as you want it to, copy the text of "mywork.py",
delete the first line, and unindent one level and save under a new
The one-best-solution (IMO):
IDE would automatically do this sort of thing with a script that is being
run --not in the interactive window which prompts you with
the ">>>" but in the script windows that are created and used to write