Status of PEP's?

James_Althoff at i2.com James_Althoff at i2.com
Fri Mar 1 17:33:44 EST 2002


[Bjorn Pettersen]
> with this syntax you have different semantics for:
>
>    for start <= i < end:
>
> And
>
>    if start <= i < end:

[David Eppstein]
> Different in what sense?
>
> "for something" loops over all values of the variable that make
> "something"  true.  Which part of "something" is the variable is
determined
> by its location in the overall expression.
>
> That is true with the current "for x in y" syntax as well as
> the suggested "for start <= i < end" syntax.
> Well, except that by "all values" substitute "all integer values"
> since it doesn't make sense to loop over all floats.

But that kind of definition isn't comprehensive enough because, for
example, it says nothing about the order of the variables as processed by
the for-loop.  If you define the for-loop in terms of an iterable object
(matching the implementation) the order is covered.  And if you stick with
an iterator-base view, then the two constructs above start to look
different since that latter is clearly based on relational operators not
iterators.

Jim





More information about the Python-list mailing list