---
source: https://iinventedlight.com/library/notes/pep-634-structural-pattern-matching.md
title: "Match a subject value with a Python case pattern"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Public-Domain (Python PEPs); PSF-2.0 (Python docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 634 – Structural Pattern Matching: Specification; Python docs, Compound statements. Public-Domain; PSF-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: PEP 634 structural pattern matching"
tags: [python, match, pattern-matching, pep-634]
client: Librarian
sources:
  - id: S1
    title: "PEP 634 – Structural Pattern Matching: Specification"
    publisher: Python PEPs
    url: https://peps.python.org/pep-0634/
    accessed: 2026-11-19
    license: "Public-Domain"
  - id: S2
    title: "Compound statements"
    publisher: Python docs
    url: https://docs.python.org/3/reference/compound_stmts.html
    accessed: 2026-11-19
    license: "PSF-2.0"
---
# Match a subject value with a Python case pattern
**Answer:** The `match` statement is used for pattern matching. It was added in version 3.10. PEP 634 provides the technical specification for the match statement. It replaces PEP 622, which was split into PEP 634 (specification), PEP 635 (motivation), and PEP 636 (tutorial).

## Subject and cases

Pattern matching takes a pattern as input (following `case`) and a subject value (following `match`). Subpatterns are allowed in the pattern. The outcomes are a match success or failure, and possible binding of matched values to a name. The `match` and `case` keywords are soft keywords.

## Reading the spec

PEP 634 is intentionally devoid of commentary; the motivation and design choices are in PEP 635. Use one `match` on the subject, then one or more `case` blocks.

| match | case |
|---|---|
| match statement | Used for pattern matching, added in 3.10 |
| subject value | Follows match |
| pattern | Follows case, may contain subpatterns |
| soft keywords | match and case |

## See also

- [python-list-comprehensions](https://iinventedlight.com/library/notes/python-list-comprehensions/)
- [python-exceptions-hierarchy](https://iinventedlight.com/library/notes/python-exceptions-hierarchy/)
- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)

## Claims

- id: C1
  claim: PEP 634 is the technical specification for the match statement, replacing PEP 622.
  source: S1
  evidence: "the technical specification for the match statement"

- id: C2
  claim: The match statement is used for pattern matching and was added in Python 3.10.
  source: S2
  evidence: "The match statement is used for pattern matching"

- id: C3
  claim: A pattern is matched against the subject value following match.
  source: S2
  evidence: "Pattern matching takes a pattern as input (following case )"

## Sources

- [S1] PEP 634 – Structural Pattern Matching: Specification. Python PEPs. https://peps.python.org/pep-0634/ . License: Public-Domain. Accessed 2026-11-19.

- [S2] Compound statements. Python docs. https://docs.python.org/3/reference/compound_stmts.html . License: PSF-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 634 – Structural Pattern Matching: Specification; Python docs, Compound statements. Public-Domain; PSF-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
