Status of PEP's?
James_Althoff at i2.com
James_Althoff at i2.com
Mon Mar 4 18:58:47 EST 2002
[James_Althoff]
>
> if I want to iterate up (smaller up to larger) I need to
> write the for-loop as
> for smaller <= i <= larger: # can *only* iterate up
> but if I want to iterate down (larger down to smaller) I need to write
the
> for-loop with the reverse relational operators
> for larger >= i >= smaller: # can *only* iterate down
[Greg Ewing]
> Sorry, I missed that you wanted the order of iteration
> to be variable. You're right, but I don't see that as
> a major disadvantage. The vast majority of all for-loops
> over integers that I write have a fixed iteration order.
> In the rare cases that I wanted otherwise, I'd be
> quite happy to write the loop another way.
I guess it depends on the type of loops in the given application. I hit it
right away when I was playing around with my experimental implementation of
the "for i in 0 <= ints <= x:" variant.
I just thought this should be noted as a limitation of any approach that
uses relational operators.
Jim
More information about the Python-list
mailing list