[Edu-sig] Using IDLE with students
John Zelle
john.zelle at wartburg.edu
Wed Aug 15 17:13:32 CEST 2007
On Wednesday 15 August 2007 9:04 am, Richard Guenther wrote:
> Sorry if this is a bit simplistic:
>
> When teaching Python to beginners and using IDLE, it seems that one of the
> dangers would be to have them assigning variables in the interactive mode
> and then maybe using them in a script they're writing. Then, when they run
> the script, the variable is still in memory so the program works--for now.
> Or, as happened recently "raw_input" gets accidentally assigned to a
> string. Then, any programs that end with "raw_input("Press Enter to exit
> this program")" will cause an error, even though the program script itself
> is fine.
>
>
> Obviously quiting and reloading IDLE will take care of this, but I was
> wondering what else may trip up students using IDLE. Maybe it would be
> nice if IDLE had an option called "Run fresh" that would clear any
> variables first....just musing here.
Provided you start IDLE in the "normal" mode, running scripts should execute
in a separate subprocess, so the kinds of interactions you describe here are
not really a problem. When running in this mode, you can also do a "restart"
under the shell menu, and this will get you a fresh interactive environment.
The problem is that the default IDLE setup in some environments starts up IDLE
with the -n switch that causes it to run without separate subprocesses for
scripts. For example, under Windows, if you right-click on a Python program
and then select "edit with IDLE" it will open in the no-subprocess mode. I
always have my students create a shortcut to IDLE in their working
directories and make sure it starts IDLE without the -n switch, and I
emphasize starting IDLE and then loading programs.
By the way, another thing that will really help is getting students in the
habit of writing scripts as functions and then just calling the function.
That way variables are local to the function/script regardless of how IDLE is
running (still doesn't solve problems like reassigning built-in functions
though).
--John
--
John M. Zelle, Ph.D. Wartburg College
Professor of Computer Science Waverly, IA
john.zelle at wartburg.edu (319) 352-8360
More information about the Edu-sig
mailing list