PEP 284, Integer for-loops

David Eppstein eppstein at ics.uci.edu
Wed Apr 3 17:11:14 EST 2002


In article <3c87f022.34099342 at news.laplaza.org>,
 mats at laplaza.org (Mats Wichmann) wrote:

> :I don't want to teach Python.  I want to teach other stuff.  
> 
> Right.  That's why I separated that out:  the intesting part is
> looping over multiple values.  range() happens to be a way to generate
> those values, but not the only way by any means, and that you don't
> like the syntax of range should have no effect on the teaching
> objective of showing how the concept of loops works....
> Mats Wichmann

Well, that's not what I want to teach either -- I want to show them how 
more advanced algorithms work, they should already have learned how 
loops work in their freshman classes or before.

Python's method of looping over general sequences is powerful and 
useful, no question.  But sometimes ranges of integers are exactly what 
you want to loop over, and for some types of integer range the Python 
range() syntax is very awkward.  Especially if you want to spend your 
attention on what you're trying to accomplish with the integer range 
loop, and not on the mechanics of coding it.

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list