An Exploration of Python's Upcoming Match Statement
summary
Python 3.10’s match statement implements PEP-634 style structural patterns: literal and or patterns for alternatives, capture patterns (underscore as wildcard) that bind values, sequence unpacking with starred captures, and mapping patterns that require specific keys but ignore extra data. Class patterns do isinstance checks plus attribute subpatterns. Examples include an event dispatcher using attribute checks and a FizzBuzz implemented by matching a remainder tuple; demos run and behave like the spec says.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 0:26Match Statement Example
- 3:18Sequence Patterns
- 4:51Mapping Patterns
- 5:34Fake Scenario
- 6:35Class Patterns
- 7:21Handling Events
- 8:41Fizzbuzz
- 9:21Outro
related talks
24mA Perfect Match The history, design, implementation, and future of Python's...
46mSupercharge your code with Python's 'match' statement
26mStructural Pattern Matching in Python
34mDynamic Pattern Matching with Python
30mAdvanced parsing of structured data using Python's new match statement
16mDynamic Pattern Matching with Python
26mThe Road to Pattern Matching in Python
42mMatch Case for Beginners
