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

-19

u/baconcleaner Mar 19 '21

omg, seriously? What was wrong in using a dict to emulate a switch-case? Do we really need new statements at this point?

6

u/CashAccomplished7309 Mar 19 '21

If you don't like the feature, you don't need to use it.

I personally like it, coming from PHP.

1

u/baconcleaner Mar 19 '21

I wasn't saying that people should not use it, I was just wondering why at this mature point in python now is necessary to have the switch. For example, I 100% agree with the introduction of the walrus operator, wich is awesome and allows to do things that were imposible to do before. But, hey, its just my world view, nobody should care.

2

u/xigoi Mar 20 '21

How were they impossible before? You could always do

foo = bar
if foo:

instead of

if foo := bar:
→ More replies (1)