Language Syntax

Pattern as — Python syntax

Match the left pattern and bind the entire subject to the name when successful. The target is a capture name, not underscore; it is distinct from names bound within the subpattern.

Formal Syntax & Structure

python syntaxpython
case pattern as name: suite

Parameters & Attributes

NameTypeDescription
patternpatternSubpattern to match.
nameidentifierCapture of entire subject.

Working Example

Example Snippetpython
match ('ok',7):    case ('ok',n) as whole:        result=n,wholeprint(result)
Python Reference