Pattern matching in Python

The sixth alpha version of the Python 3.10 was released today (the final release is planned for October). It introduces (with PEP 634) new great feature — pattern matching. Let’s see how it works!

Like a switch

The syntax a little bit resembles the switch statement, known from the other programming languages: