PEP 276 Simple Iterator for ints (fwd)

David Eppstein eppstein at ics.uci.edu
Fri Nov 16 17:50:13 CET 2001


In article <a7aJ7.43083$vQ1.1407989 at atlpnn01.usenetserver.com>,
 "Steve Holden" <sholden at holdenweb.com> wrote:

> Well in the interests of getting Python into your teaching, might I suggest
> that you simply describe [x]range(n) as producing the range of subscripts
> required to index the elements of a sequence of length n?

But, when I need to index a sequence, I use "for item in sequence",
it's only for the non-sequence-indexing uses of for loops that I use ranges.

> Since it's presumably computer science you are teaching, your students
> should be familiar enough with the (mathematically justifiable, but equally
> pragmatically justifiable) advantages of numbering from zero. If not, then
> arguably they won't be learning much computer science anyway, though I have
> no objection to their tinkering with programming ;-)

The reason they're familiar with numbering from zero is that we switched 
from Pascal to C/C++/Java in our introductory courses several years ago.  
It has very little to do with mathematical or pragmatic justification.
-- 
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