Language Syntax

Pattern literal — Python syntax

Match literal values using equality for ordinary numeric and string literals, and identity for None, True and False. This is pattern grammar, not arbitrary expression evaluation.

Formal Syntax & Structure

python syntaxpython
case 0:    suite# Other literal patterns include strings, None, True and False.

Working Example

Example Snippetpython
def classify(v):    match v:        case True:            return 'bool'        case 1:            return 'one'        case _:            return 'other'print((classify(True),classify(1),classify(1.0)))
Python Reference