PEP 284, Integer for-loops

Paul Rubin phr-n2002a at nightsong.com
Thu Mar 7 18:27:01 EST 2002


Courageous <jkraska at san.rr.com> writes:
> >This syntax could easily be extend, to allow a step other than 1:
> >
> >   for i = 1 to 10 step 3:
> 
> Or:
> 
> 	for i = 10 to 1 step -1:

This is fine.

> Further, in ranges which step from high to low, the step can be
> inferred.

This doesn't sound good.  Suppose you say

      for i = a to b:

where you don't know at compile time the values of a and b.
Do you really want it to count backwards if b < a?   I usually wouldn't.



More information about the Python-list mailing list