PEP 276 Simple Iterator for ints (fwd)

Bengt Richter bokr at accessone.com
Tue Dec 11 20:31:30 EST 2001


On Tue, 11 Dec 2001 16:43:16 -0700, "Bjorn Pettersen" <BPettersen at NAREX.com> wrote:

>> From: Bengt Richter [mailto:bokr at accessone.com]=20
>>=20
>> On Tue, 27 Nov 2001 10:27:31 -0800, James_Althoff at i2.com wrote:
>>=20
>> >
>> >Greg Ewing wrote:
>> >>While trying to think of a range syntax that looks unambiguously=20
>> >>half-open without clashing with list or tuple constructors, the=20
>> >>following blindingly obvious solution occurred to me:
>> >>
>> >>  for 0 <=3D i < 5:
>> >>    ...
>> >
>> >Greg,
>> >
>> >Since this looks like a suggestion for replacing xrange in=20
>> the general=20
>> >case, did you have any thoughts on how one might specify a=20
>> step value?
>> >
>>=20
>> How about if a bare [x:y:z] were interepreted as an=20
>> abbreviation for slice(x,y,z) and you defined what one might=20
>> expect as an iterator for the slice type?
>>=20
>> 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.
>
Not exactly. The notation looks the same, but UIAM PEP 204 notation resulted
in a list type, whereas I was suggesting generating a slice type, which would
define a different iterator.



More information about the Python-list mailing list