PEP 276 Simple Iterator for ints

James_Althoff at i2.com James_Althoff at i2.com
Thu Nov 15 13:14:18 EST 2001



David Eppstein wrote:
>
> Skip Montanaro <skip at pobox.com> wrote:
>
>> I think I would still write the above as
>>
>>     for rowcount in [0, step, ... table.getRowCount()]:
>>
>> That would get you the sequence
>>
>>     0, 1*step, 2*step, ... (table.getRowCount()-1)*step
>>
>> and is more flexible than your proposal.  There's no reason you couldn't
>> have
>>
>>     for f in [0.0, 1.0, ... sys.maxint]:
>>
>> to enumerate floats up to but not including sys.maxint (care needs to be
>> taken to not to compound errors).
>>
>> You could also build character sequences I think:
>>
>>     for c in ["a", "b", ... "z"]:
>
>You seem to be inconsistent here about whether you want these ranges to be

>open or closed on the right.  I think closed is the only reasonable choice

>for this syntax.

I agree with David that the syntax above probably sets one's expectation
that the interval is closed on the right.  Unfortunately, that
interpretation would necessitate a "subtract 1" idiom for indexing
sequences.

Jim






More information about the Python-list mailing list