Language Syntax

Pattern group — Python syntax

Parenthesize a pattern without changing its matching semantics. A comma distinguishes a sequence pattern from grouping; grouping can make OR and AS precedence clearer.

Formal Syntax & Structure

python syntaxpython
case (pattern): suite

Working Example

Example Snippetpython
match 2:    case (1 | 2):        result='matched'print(result)
Python Reference