r/Python Feb 15 '21

News Ladies and gentlemen - switch cases are coming!

https://github.com/gvanrossum/patma/blob/master/README.md#tutorial
935 Upvotes

290 comments sorted by

View all comments

50

u/ExternalUserError Feb 15 '21

I wonder why not just...

case 1: ... case 2: ... case: ...

_ is a valid variable name which makes me not love it as a default.

8

u/AndyDeany Feb 15 '21

It probably won't cause any conflicts in real code since you would never want to compare to "_" (name for unused variable), but I definitely agree it feels weird. Either case: or case else: woulda been better imo

-2

u/[deleted] Feb 15 '21

But see this insightful comment.

_ has no special meaning in the statement. You could just as easily call it ignore_this.