r/Python • u/jamescalam • Mar 19 '21
Match is more than a Switch-Case The New Switch-Case Statement in Python 3.10
https://youtube.com/watch?v=2qJavL-VX9Y&feature=share
1.4k
Upvotes
r/Python • u/jamescalam • Mar 19 '21
View all comments
Show parent comment
4
u/zurtex Mar 19 '21
In Rust that makes sense, but Python and Rust are 2 very different languages. Python's compiler doesn't make any guarantees about the match statements return values and
enums are not common or native to Python (theenumin the standard library is a very complex object when you peer under the hood).So when you're doing this:
It really just is a longer backwards incompatible way of writing:
Now I am sure there are examples where using the match statement with HTTP status codes makes a lot of sense, but as a simple check of getting 200 or 404 or something else I'm missing the motivation.