Range Operation pre-PEP

Greg Ewing see at my.signature
Fri May 11 01:32:24 EDT 2001


Roman Suzi wrote:
> 
> I taught programming classes a year ago.
> That is where I had some trouble with for-loops.

Maybe that's because you were trying to teach
Python for-loops as though they were Pascal for-loops,
which are designed to generate a sequence of
integers.

That's not what Python for-loops are designed for.
The purpose of a Python for-loop is to do something
for each element of a sequence, and I believe that's
how they should be presented.

It follows from this that there's no reason to
introduce for-loops until you've introduced some
kind of sequence, e.g. a list of strings.

If you want to introduce a looping structure for
some other purpose before then, don't use a for
loop, use a while loop.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list