PEP 276 Simple Iterator for ints (fwd)

Steve Holden sholden at holdenweb.com
Fri Nov 16 10:22:03 EST 2001


"David Eppstein" <eppstein at ics.uci.edu> wrote in message
news:eppstein-54CAED.14040815112001 at news.service.uci.edu...
> In article <2YTI7.30749$vQ1.1137481 at atlpnn01.usenetserver.com>,
>  "Steve Holden" <sholden at holdenweb.com> wrote:
>
> > Whether or not either comma is (even optionally) necessary
syntactically,
> > the main problem with any such representation is the impedance mismatch
with
> > [x]range(), which are built on the half-open interval. Particularly
> > difficult to explain the mismatch to newbies, I think.
> >
> > If I have a vote, I'm afraid it's -1
>
> OK, but my problem is precisely the impedance mismatch between range and
> newbies -- do you really think that they come pre-equipped with an
> understanding of range and half-open intervals?  I am happy enough with
> [x]range when it comes to programs that I write for myself, but would like
> a more intuitive syntax for using in algorithms lectures where I can't
> expect the students to know Python syntax.
>
> It sounds like too many Pythonists see this as a non-problem, so it is
> unlikely to change and I will continue using non-Python for my lectures.

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?

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 ;-)

This thread has mixed discussions on the utility of half-open intervals with
the possibility of the notational extensions proposed in the PEP.
Ultimately, do we want a notation for producing *other* types of interval,
or are we satisfied with having to produce them all using the current
half-open style?

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list