"Data blocks" syntax specification draft

Marko Rauhamaa marko at pacujo.net
Wed May 23 02:05:40 EDT 2018


Christian Gollwitzer <auriocus at gmx.de>:
> I'd think that the definitive answer is in the grammar, because that is
> what is used to build the Python parser:
>> 	https://docs.python.org/3/reference/grammar.html
>> Actually, I'm a bit surprised that tuple, list etc. does not appear
> there as a non-terminal. It is a bit hard to find, and it seems that
> "atom:" is the starting point for parsing tuples, lists etc.

testlist and testlist_comp are the interesting entities.
The syntax definition does not help you understand the semantics. For
example, omitting yield_expr and testlist_comp in
 atom: ('(' [yield_expr|testlist_comp] ')' |
evaluates to a tuple and nothing in
 testlist: test (',' test)* [',']
suggests what effect the the presence or absence of the final ',' could
have on the evaluation.
Marko


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /