PEP 276 Simple Iterator for ints (fwd)

Christopher A. Craig com-nospam at ccraig.org
Thu Nov 15 17:44:55 CET 2001


James_Althoff at i2.com writes:

> Magnus Lie Hetland wrote:
> >  for i in 1 .. 10: print i
> >
> >or
> >
> >  for i in 0, 2 .. 20: print i
> >
> >But I guess getting this in as part of the language isn't very realistic.
> 
> Which of the below would "0 .. 5" specify?
> 1) 0,1,2,3,4,5
> 2) 1,2,3,4
> 3) 0,1,2,3,4
> 4) 1,2,3,4,5

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]"?  

-- 
Christopher A. Craig <com-nospam at ccraig.org>




More information about the Python-list mailing list