Nick Coghlan wrote:
> However, the scoping of for loop
> variables won't change, as the current behaviour is essential for search
> loops
> that use a break statement to terminate the loop when the item is found.
It occurs to me that there's a middle ground here:
leave the loop variable scope alone, but make it
an error to use the same variable in two different
loops at the same time.
e.g.
for x in stuff:
if its_what_were_looking_for(x):
break
snarfle(x)
for x in otherstuff:
dosomethingelse(x)
would be fine, but
for x in stuff:
for x in otherstuff:
dosomethingelse(x)
would be a SyntaxError because the inner loop
is trying to use x while it's still in use by the
outer loop.
--
Greg
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com