PEP 276 Simple Iterator for ints (fwd)

David Eppstein eppstein at ics.uci.edu
Thu Nov 15 12:59:43 EST 2001


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.
-- 
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