Match Case for Beginners
summary
Introduces Python 3.10 structural pattern matching (match/case) and demonstrates using it with guards, sequence and starred patterns, and a tuple-of-remainders trick to solve seven concrete problems: word translation, month days, Roman numerals 1–1000, card ranking, FizzBuzz 1–100, a 9-element magic square, and flattening nested lists. Compares match/case implementations to alternatives (notably dictionaries), measures practicality and performance, and warns that the Roman-numeral example is an overuse that auto-generates matching code.
AI-written summary · about
chapters (4)
- 0:00Start
- 8:05Translate Spanish words to English using the vocabulary from the song "Pollito Chicken".
- 15:47Convert any integer from 1 to 1000 to its corresponding Roman numeral value.
- 18:46From a card in a standard English deck represented as a tuple of rank, suit, determine its numerical value.
related talks
10mAn Exploration of Python's Upcoming Match Statement
46mSupercharge your code with Python's 'match' statement
18mmeet the best feature in python 3.10: match-case
26mStructural Pattern Matching in Python
26mThe Road to Pattern Matching in Python
30mAdvanced parsing of structured data using Python's new match statement
16mDynamic Pattern Matching with Python
34mDynamic Pattern Matching with Python
