PEP 284, Integer for-loops

David Eppstein eppstein at ics.uci.edu
Wed Mar 6 12:12:47 EST 2002


On 3/6/02 11:08 AM -0600, Skip Montanaro wrote:
> Why is an or_expr non-terminal between the two comparisons?  Shouldn't it
> be a target_list?

I wanted the grammar to enforce exactly the same precedence rules as in 
expressions, and the easiest way to do that was to use the same tokens as 
in the corresponding part of the expression grammar.

Also, target_list isn't right because the proposed for-loop syntax only 
allows looping over one integer at a time, not a tuple of integers.

But perhaps there's a better choice than or_expr that would flag more 
non-lvalues as syntax errors...suggestions welcome.

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/





More information about the Python-list mailing list