PEP 276 Simple Iterator for ints (fwd)
Greg Ewing
greg at cosc.canterbury.ac.nz
Thu Nov 29 19:44:17 EST 2001
James_Althoff at i2.com wrote:
>
> I would have guessed, though, that given the current direction of Python
> vis-a-vis iterators that
>
> for 0 <= x < 5:
>
> would have to mean something like "0 <= x < 5" is special syntax built into
> the for-loop statement that generates an iterator that enumerates the
> integers 0,1,2,3,4.
Yes.
> It happens to look just like an expression which
> *outside* the context of a for-loop evaluates to 0 or 1 instead of
> producing an iterator (as was pointed out previously by Peter Hansen).
This is also true of the "i in seq" part of "for i in seq",
so nothing unprecedented would be going on in that respect.
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list