What is the purpose of ','. expression in Python grammar specification?

Question:

Can you help me with the args part in Python grammar specification?

args:
    | ','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ [',' kwargs ] 
    | kwargs 

Especially this part: ','.(starred_expression | ( assignment_expression | expression !':=') !'=')+. What does ','. mean?

I checked https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form and https://en.wikipedia.org/wiki/Parsing_expression_grammar, but could not find a reference to that.

Asked By: abyesilyurt

||

Answers:

PEP 617 describes the syntax used by the grammar specification. In particular, s.e+ means one or more es separated by ss.

So args is a sequence of one or more various expressions separated by commas.

Answered By: chepner
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.