[Tutor] Local Unbound Mystery

Alan Gauld alan.gauld at btinternet.com
Sat Sep 20 14:32:42 CEST 2008

"Wayne Watson" <sierra_mtnview at sbcglobal.net> wrote 

> I do not think I've made an inaccurate observation. 
> Is it possible the IDLE shell is leaving something 
> behind that I can't see? 

That's very possible. The interpreter will remember its 
previous state for as long as its running so if you import 
your module into the shell, say, it will remember it, 
similarly if you try some code out that uses the same 
name as the variable in your script it can confuse the 

That's why, when in doubt, always run your code outside 
of any IDE to find out its true behaviour. IDEs 
(including IDLE) are very useful tools but they can mislead 
as well.

> I just inserted the global statement in the full program

I'm not quite sure what you mean by this, but I assume 
you mean you had a simplified version of the problem 
plus the full application code that you were working on?


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list