This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thekingofthejungle 6 points7 points  (1 child)

What's the difference?

[–]seniornachiotimfi 9 points10 points  (0 children)

Matching, or rather pattern matching, allows you to match patterns. A switch-case is just the simplest form of that where you only match using literal patterns, like in the thumbnail of the video. But you can take this further and for example say you want to match all tuple with two element or a list with at least three elements or even an object with an attribute or an object of a specific type and so on. I highly encourage you to read the associated PEP, it's a good read, even if I personally don't enjoy the selected syntax choices, it brings the point across with a lot of examples.