PEP 276 Simple Iterator for ints (fwd)

James_Althoff at i2.com James_Althoff at i2.com
Wed Nov 28 20:31:52 EST 2001


Greq Ewing wrote:
>I think the point Mr. Eppstein was making is that
>"for i in seq" can be read as "for all values of i
>such that i in seq is true". PEP 276 would break
>that, because "for i in 5" couldn't sensibly be
>read as "for all values of i such that i in 5
>is true", unless "i in 5" on its own were valid and
>had a rather unintuitive meaning.

But since Python now uses iterator protocol -- not sequence protocol -- in
for-loops (presumably in "in" as it were) and such, I would assume that
over time

    for i in spam:

would come to be thought of as "for all values of i generated from spam's
iterator".

I don't think PEP 276 "breaks" that.  It, in fact, proposes that
types.IntType *implement* that.  Obviously there are myriad differences of
opinion on this.  :-)

Jim





More information about the Python-list mailing list