PEP 276 Simple Iterator for ints (fwd)

Steve Holden sholden at holdenweb.com
Thu Nov 15 19:41:24 CET 2001


"David Eppstein" <eppstein at ics.uci.edu> wrote in message
news:eppstein-5F01F0.09594315112001 at news.service.uci.edu...
> In article <mailman.1005842727.15557.python-list at python.org>,
>  com-nospam at ccraig.org (Christopher A. Craig) wrote:
>
> > You think that is bad.  What do you think "1, 2 .. 5" specifies?
> >
> > 1) 1, 2, 3, 4, 5
> > 2) 1, 3, 5
> > 3) 1, 3
> >
> > If I saw it on a math paper, I would immediately presume (1).  After
> > all, (2) and (3) don't even include "2" which, it would seem should be
> > the second element of the sequence.  If it is (1), then what do we do
> > about "0, 2 .. 6"?  Is this "[0, 2, 5]"?
>
> No, it is [0,2,4,6].
> More generally, as I said before, I would expect [a, b, ... c]
> to be essentially equivalent to range(a, c+b-a, b-a) -- i.e.
> the step size should be b-a and the last element in the range should be c.

Wouldn't conventional mathematical notation (rather than Haskell, about
which I have no knowledge) use a comma both before and after the ellipsis?
i.e., {1,2,3,4,5} would be shown as

    1, 2, ..., 5

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

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








More information about the Python-list mailing list