Andreas Tawn wrote:
the for-in loop does ordinary assignments in the current scope:
"Each item in turn is assigned to the target list using the
standard rules for assignments, and then the suite is executed."
somewhat simplified, "for vars in expression: code" is equivalent to
inlining:
_ = iter(expression )
while 1:
try:
vars = _.next()
except StopIteration:
break
else:
body
where "_" is an internal variable.
</F>
I never knew that and I can't find reference to it in the docs.
"Each item in turn is assigned to the target list using the
standard rules for assignments, and then the suite is executed."
somewhat simplified, "for vars in expression: code" is equivalent to
inlining:
_ = iter(expression )
while 1:
try:
vars = _.next()
except StopIteration:
break
else:
body
where "_" is an internal variable.
</F>