Nested For and While Statements
metawilm at gmail.com
metawilm at gmail.com
Tue Sep 25 13:48:29 EDT 2007
On Sep 25, 7:07 pm, Zentrader <zentrad... at gmail.com> wrote:
> Note that in list comprehension, [x for x in (1, 2, 3)], the
> for loop allocates memory the same way, but the scope changes so that
> "x" is visible outside the for loop,
How is this different? The variable spilling of list comprehension is
the same as for regular for loops. The (#) and (##) lines below don't
print the same value of j.
>>> for j in range(3):
... print j, "first loop" (#)
... for j in range(3):
... print " ", j, "2nd loop"
... print j, "first loop, again?" (##)
- Willem
More information about the Python-list
mailing list