[Python-ideas] if-syntax for regular for-loops

Arnaud Delobelle arnodel at googlemail.com
Sun Oct 12 21:21:33 CEST 2008

On 12 Oct 2008, at 19:38, dbpokorny at gmail.com wrote:
> On Oct 10, 12:51 pm, Arnaud Delobelle <arno... at googlemail.com> wrote:
>> There is also a problem with parsing as:
>> * the following is correct:
>>      for i in L1 if cond else L2:
>>         do_something()
>> * Python's grammar is LL(1)
> Not really.

What do you mean? Python's grammar is not LL(1)? Or Python + for-in-if  
statements is still LL(1)?

> for_stmt: 'for' exprlist 'in' testlist ['if' or_test] ':' suite
> ['else' ':' suite]

What does that prove?

If I show you:

    for i in L if

How do you know, without looking at further tokens,  whether the 'if'  
is part of an if-expression or part of a for-in-if statement?


More information about the Python-ideas mailing list