Language Syntax

Pattern capture — Python syntax

Bind the subject to an unqualified name other than underscore. A standalone capture always succeeds, so it must not make later cases unreachable. It does not compare with an existing variable of that name.

Formal Syntax & Structure

python syntaxpython
case name: suite

Working Example

Example Snippetpython
value=0match ('ok',7):    case ('ok',value):        result=valueprint((result,value))
Python Reference