Mention flat indentation 'match: expression'

This commit is contained in:
Guido van Rossum 2020-06-24 21:26:17 -07:00
parent 770d36cc01
commit fa90054ead
1 changed files with 13 additions and 1 deletions

View File

@ -1168,7 +1168,19 @@ In sample programs using `match`, written as part of the development of this
PEP, a noticeable improvement in code brevity is observed, more than making up
for the additional indentation level.
TODO: flat indentation with "match: expression" at the top.
Another proposal considered was to use flat indentation but put the
expression on the line after ``match:``, like this::
match:
expression
case pattern_1:
...
case pattern_2:
...
This was ultimately rejected because the first block would be a
novelty in Python's grammar: a block whose only content is a single
expression rather than a sequence of statements.
Alternatives for constant value pattern