Python 3000 idea: reversing the order of chained assignments

Duncan Booth duncan.booth at invalid.invalid
Thu Mar 22 17:17:16 CET 2007

Steve Holden <steve at> wrote:

> In other words,
> assignment_stmt       ::=       (target_list "=") expression_list |
>                                   (target_list "=") assignment_stmt
> and
> assignment_stmt       ::=       (target_list "=") assignment_stmt |
>                                   (target_list "=") expression_list
> are entirely equivalent

I'm not quite sure what you are getting at. An assigment_stmt and an 
expression_list are not ambiguous so those two productions are identical 
(not just equivalent). Perhaps you are thinking of productions like:

    m_expr ::= u_expr | m_expr "*" u_expr  

which will match the same input, but could produce a different parser 
output than:

    m_expr ::= u_expr | u_expr "*" m_expr  

> I'm sure you understand that syntax only specifies what's legal, not how
> it should be interpreted.

I agree that the syntax does not mandate how it should be interpreted,
but it does lead to expectations.

If the expression_stmt is hidden from the outer assignment_stmt by an inner 
one then it is reasonable to expect that the inner production will be 
completely evaluated before the outer assignment happens. i.e. right to 

More information about the Python-list mailing list