Status of PEP's?

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Mar 5 19:01:04 EST 2002


David Eppstein wrote:
> 
> Checking that the outer expressions contain one item rather than a tuple
> needs to be done at run time.  Of course, the compiler can catch some
> instances where the expression is obviously non-single.

I expressed myself a bit cryptically there. What the
grammar should *really* say is

for_stmt: 'for' (exprlist 'in' testlist 
       | expr lt_op something lt_op expr ...

but that would lead to a conflict between 'exprlist'
and 'expr', so I made them both 'exprlist' with the
intention that it would be restricted to a single
'expr' later. But since a run-time test is needed
anyway, it mightn't be worth the bother.

> the outer expressions should be or_expr to respect Python's
> precedence rules

I can't find 'or_expr', but I'm looking at the 1.5.2
grammar. Has it been added later?

> and the inner one should be identifier.

That's a bit too restrictive -- any lvalue should be
allowed (as for-in does). Unfortunately there's no
grammar symbol corresponding exactly to an lvalue.

-- 
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