I understand generally how scoping works in Python for loops. My question is why the design decisions were made in this way. For example:
for foo in xrange(10):
bar = 2
The above will print (9,2).
T'foo' is really just controlling the loop, and 'bar' was defined inside the loop. I can understand why it might be necessary for 'bar' to be accessible outside the loop (otherwise, for loops would have very limited functionality).
What I don't understand is why it is necessary for the control variable to remain in scope after the loop exits. I'd appreciate if anyone threw some light at this!