a = b = 1 just syntactic sugar?

Ed Avis ed at membled.com
Sun Jun 8 06:26:23 EDT 2003


martin at v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) writes:

>>Elsewhere in this thread I proposed using a simple_stmt as the body of
>>a lambda.  Still, if you say there has been years of discussion I am
>>not so foolish as to think I've found the answer.
>
>Then your examples don't follow your proposal. A simple_stmt ends with
>a NEWLINE,

Are you sure?  This is an excerpt from
<http://python.org/doc/current/ref/grammar.txt>:

>simple_stmt ::= expression_stmt
>                | assert_stmt
>                | assignment_stmt
>                | augmented_assignment_stmt
>                | pass_stmt
>                | del_stmt
>                | print_stmt
>                | return_stmt
>                | yield_stmt
>                | raise_stmt
>                | break_stmt
>                | continue_stmt
>                | import_stmt
>                | global_stmt
>                | exec_stmt
>
>expression_stmt ::= 
>             expression_list

and elsewhere,

>expression_list ::= 
>             expression ( "," expression )* [","]

So just picking expression_stmt as an example, since it happens to be
the first in the list, I don't see anything indicating that it ends in
a newline.  Presumably the other cases for simple_stmt such as
assert_stmt and assignment_stmt do not end with a newline either.

On the other hand, it seems clear that the places which mention
simple_stmt then go on to add a newline:

>stmt_list ::= 
>             simple_stmt (";" simple_stmt)* [";"]

>statement ::= 
>             stmt_list NEWLINE | compound_stmt

So I don't see why a rule that lets lambda contain a simple_stmt would
mean having to end it with a newline.

-- 
Ed Avis <ed at membled.com>




More information about the Python-list mailing list