no side effects
jon_bills at hotmail.com
Wed Jan 8 14:33:11 CET 2003
Michele Simionato wrote:
> I was surprised by the following code:
>>>> for i in [1,2,3]:
> ... print i,
> ... i=3
> I would have expected only 1 to be printed, but instead Python
> continues the loop without noticing that the value of i has
> changed. IOW, no side effect.
"The suite may assign to the variable(s) in the target list; this does not
affect the next item assigned to it. "
More information about the Python-list