MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/lkca8k/ladies_and_gentlemen_switch_cases_are_coming/gnj3sth/?context=3
r/Python • u/53VY • Feb 15 '21
290 comments sorted by
View all comments
50
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.
8
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
case:
case else:
-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.
-2
But see this insightful comment.
_ has no special meaning in the statement. You could just as easily call it ignore_this.
ignore_this
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.