no side effects

Chad Netzer cnetzer at mail.arc.nasa.gov
Wed Jan 8 18:00:19 EST 2003


On Wednesday 08 January 2003 14:36, Nagy László wrote:
> 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.

And furthermore, Python can loop over arbitrary objects.  So as a thought 
experiment, how would one expect these to work (assuming you were from the C 
mindset)?

for i in ["a","b","c"]:
   print i,
   i = 3

or

for i in "abc":
   print i,
   i = 3

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
cnetzer at mail.arc.nasa.gov





More information about the Python-list mailing list