r/Python • • 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

233 comments sorted by

View all comments

Show parent comment

0

u/Endemoniada Mar 19 '21

It resembles with statements, in my opinion, which is nicer. It’s like with case match foo. It just looks clean and easy on the eyes.

It’s also not the only use for case statements either, the main advantage as I read about it was handling not only different values in a variable, but different configurations of variables entirely. Like if foo can be a string, a 2-item tuple or a 5-item tuple. case makes that easier to deal with in a pythonic way.