[Tutor] Re: using IDLE and changing variables
Christopher Smith
csmith@blakeschool.org
Sat, 04 Aug 2001 20:04:09 -0500
alan.gauld@bt.com writes:
>> Let's say at one point you had a variable x defined
>> and you used it in several places. Then you change
>> the variable from x to y but forget to change it
>> everywhere.
>
>That'd be a programmer error in every environment I've
>ever used. Some language compilers will tell you if you
>remove the original declaration/definition of the variable
>(x in your case) and then try to use it. Python will
>warn you in some situations. But it has nothing to do
>with IDLE per se, it's all to do with Python itself.
(Sorry, I meant IDE.)
Yes, I realize that it's an error on the programmer's
part, but Python usually knows enough to warn you. The
reason I suggested that it was an IDE error is that
if it purged memory before running a script that you are
working on it woud realize that an error was occuring.
Here's a really simple demonstration of what I mean:
#new script
x=2
print x
(when you run this you see "2" printed in the output window.)
#modified
print x
You still see "2" printed in the output window.
>> I guess what I'm looking for is something like BASIC's "new"
>> command that flushes out everything of the session and begins
>> fresh.
>
>The interactive prompt doesn't have that feature but
>working in IDLE the best thing IMHO is simply to create
>a new file using File|New...
Yes, I see that's a good approach. It appears that
each user created script window and the interactive window
keep track of their own variables and modules.
>
/c
>