PEP 276 Simple Iterator for ints (fwd)

Jeff Shannon jeff at
Thu Nov 29 02:50:56 CET 2001

David Eppstein wrote:

> I take it you are viewing the syntax of a for-loop as
>   "for" variable "in" expression:
> where "for" and "in" are keywords and expression must be something that
> returns a list or iterator.  So the "in" of a for-loop has very little
> other than spelling to do with "in" operator for list expressions.
> I would rather view a for-loop as
>   "for" expression:
> where (currently) the expression must have as its top level operation the
> "in" operation and the lhs must be a variable.  The variable is set in all
> possible ways that make the expression true.  From this point of view, "for
> x in 5" looks really ugly, and "for 0 <= x < 5" makes a lot more sense: we
> now simply allow one more kind of expression in a for loop, one where the
> top level is a three-way comparison and the middle side of the comparison
> must be a variable.

It seems to me that the first of these is by far the more intuitive way to view
this.  Of course, this may well be due to my relative lack of understanding of
advanced mathematics and computer science.  Conversely, one could argue that the
whole point of making a language intuitive, is to appeal to people with a lack of
understanding of advanced mathematics and computer science...

Jeff Shannon
Credit International

More information about the Python-list mailing list