no side effects

Nagy László nagylzs at freemail.hu
Wed Jan 8 17:36:26 EST 2003


Another explanation for a newbie would be this.

When comparing C++ (or other similar language) and Python for loop,
the first thing I would mention is that in C++, a for loop is terminated 
by a condition
but in Python, there is no condition anyway.

So in this program:

 >>>>for i in [1,2,3]:
 > ...     print i,
 > ...     i=3

or even in this one:

 >>>>for i in [1,1,1]:
 > ...     print i
 > ...     i = 1

of course the loop won't be terminated after the first
iteration (no reason to do that).

  Laci 1.0







More information about the Python-list mailing list