Thought on PEP 204 and 276

phil hunt philh at comuno.freeserve.co.uk
Tue May 28 15:06:05 EDT 2002


On Tue, 28 May 2002 12:14:05 +0100, Steve Horne <steve at lurking.demon.co.uk> wrote:
>
>I'll admit that I didn't think of that, but Ints[a:b:c] has no
>advantage over range(a,b,c). 

I don't think it is either.

>The real issue is not...
>
>  for i in range(10) :

I used to think that

   fir i in x:

where (x) is an intreger, was confusing. But lately, I've found 
myself accidently spontaneously typing it myself instead of range(x)
so i guess it makes intuitive sense after all.

>but...
>
>  for i in range(len(list)) :
>
>and other, even longer, expressions where the range becomes annoying.

I agree this is too long. vThe last tinme this was discussed, the 
consensus was that it should be replaced by 

   for i in list.keys():

modelled on the dict.keys() method.

>  for i in range(1, 10) :
>
>which can become...
>
>  for i in inclusive (1, 9) :
>
>or...
>
>  for i in exclusive (0, 10) :

i've toyed with the idea of a fromto() function, where fromto(a, b)
returns the same as range(a, b+1). There could also be xfromto(),
like xrange().

I'm not sure if 'fromto' is the best name, mind.


-- 
<"><"><"> Philip Hunt <philh at comuno.freeserve.co.uk> <"><"><">
<"><"><">   My website has moved -- new address is:  <"><"><"> 
<"><"><">    <http://www.comuno.freeserve.co.uk/>    <"><"><"> 



More information about the Python-list mailing list