PEP 276 Simple Iterator for ints (fwd)

Bjorn Pettersen BPettersen at NAREX.com
Tue Dec 11 18:43:16 EST 2001


> From: Bengt Richter [mailto:bokr at accessone.com] 
> 
> On Tue, 27 Nov 2001 10:27:31 -0800, James_Althoff at i2.com wrote:
> 
> >
> >Greg Ewing wrote:
> >>While trying to think of a range syntax that looks unambiguously 
> >>half-open without clashing with list or tuple constructors, the 
> >>following blindingly obvious solution occurred to me:
> >>
> >>  for 0 <= i < 5:
> >>    ...
> >
> >Greg,
> >
> >Since this looks like a suggestion for replacing xrange in 
> the general 
> >case, did you have any thoughts on how one might specify a 
> step value?
> >
> 
> How about if a bare [x:y:z] were interepreted as an 
> abbreviation for slice(x,y,z) and you defined what one might 
> expect as an iterator for the slice type?
> 
> Then you could write
>     for i in [0:5]:   # or [:5]
>         ...

PEP 204 (http://python.sourceforge.net/peps/pep-0204.html) suggested
exactly this and was rejected.

-- bjorn




More information about the Python-list mailing list