Keywords and Control Flow
_ — Wildcard pattern
Within a match pattern, a single underscore is a wildcard that accepts a value without creating a binding. A starred wildcard can discard remaining sequence items. Outside patterns, underscore is an ordinary identifier; REPL and translation conventions are separate behaviors. An unguarded wildcard case is irrefutable and must be last. It is not a variable that stores the discarded match.
Formal Syntax & Structure
python syntaxpython
case _: suite
case [first, *_]: suiteWorking Example
Example Snippetpython
_ = "unchanged"match [7, 8, 9]: case [first, *_]: print(first)print(_)