iters on ints? (reducing the need for range/xrange)

Michael Robin me at mikerobin.com
Fri Nov 9 23:03:28 EST 2001


Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote in message news:<slrn9uo3f2.qbd.qrczak at qrnik.zagroda>...
> 9 Nov 2001 08:51:05 -0800, Michael Robin <me at mikerobin.com> pisze:
> > 
> > Only one of these can work - the above are either equivalent to
> > the interval [0..9] or [0..10]
> 
> No, they both work, because it would be equivalent to [0..9].

Well, there is no "it" right now - but I assume that's
what you want it to mean.

I was just saying that I think in most other 
languages that specify numeric targets of "for"
without extra syntax or an explicit test expression
the endcases are inclusive. (Pardon me if I'm
wrong on any of these...) Consider:

   for i = 0 to 10
   (0 to: 10) do:
   for I in 0..10 loop
   for i := 0 to 10 do begin
   (loop for i from 0 to 10 do ...)
   
all have their last iters at 10. 
So, if 
   for i in 10: 

doesn't include 10, it could be confusing.
But I guess if it's used only as a shortcut for range(len()),
I guess it does the right thing. (But I still like
range(seq) more then len(seq) as shorthand for
range(len(seq)).)

m



More information about the Python-list mailing list