Page Body

Case / Switch Comes to Python in 3.10

Mike Driscoll, Mouse Vs Python:

Python 3.10 is adding a new feature called Structural Pattern Matching, which is defined in PEP 634 and has a tutorial on the topic in PEP 636. Structural Pattern Matching brings the case / switch statement to Python. The new syntax goes beyond what some languages use for their case statements.

This tutorial's aim is to get you acquainted with the new syntax that you can use in Python 3.10. But before you dive into this latest incarnation of Python, let's review what you could use before 3.10 came out.

Enjoyed this post?

Subscribe to the feed for the latest updates.