[Tutor] Up All Night with IDLE.
Sun, 14 Jan 2001 18:57:05 +0100
I have had the same trouble after using 'import' in the python shell. IDLE (and Python) have nice
features (like ctrl-f5) but I can not get used to this stuff. I have red something about 'reload' in the
manual but I prefer a more old-fashioned way.
1) I write a very simple script like 'test.py'
open a command shell, and after saving the source in IDLE, I enter "python test.py" (and use F3
for the next test)
2) I create a link on my desktop which I double-click after saving the source
3) I create the source-file on my desktop and after defining the correct 'open' and 'edit' in the
Windows Explorer, I can double-click the icons
edit -> c:\python20\pythonw.exe c:\python20\tools\idle\idle.py -e "%1"
open -> C:\Python20\pythonw.exe "%1" %
The goal of these methods is to invoke a new shell (and clean environment too). The methods
are a little bit Windows-style but they can be implemented in the Unix shell too. This way of
testing (always do a fresh start) have saved me in several operating systems.
On 14 Jan 2001, at 10:06, Tesla Coil wrote:
> I'm in IDLE and I write:
> def foobar():
> print 'foobar'
> Save as krock.py, run it, prints foobar.
> I return to the editor and modify the function:
> def foobaz():
> print 'foobaz'
> Save, run, prints foobar.
> Larger program, more complex functions, awake all night,
> rewriting foobaz, mystified that output is still foobar...
> Shut down, restart IDLE, reload krock.py run it again:
> NameError: There is no variable named 'foobar'
> I'll give myself a little credit: I figured it out without that.
> I would prefer to get a NameError without shutting down IDLE.
> Is there a line I could put at the top of programs to assure
> I'll be in uncorrupted namespace on every test run?