Hacker News new | ask | show | jobs
by duckerude 2176 days ago
Python is likely to get pattern matching in 3.10, at least: https://www.python.org/dev/peps/pep-0622/
1 comments

Alas, not as an expression. Just a statement. I couldn't disagree more with that decision.
Python has a long-standing rule that you can't nest statements inside expressions. In my opinion, this is a good rule for a whitespace-sensitive language. (This is also why lambdas can only be a single expression.)

Thus, making match an expression would imply that each case must also be an expression, which would seriously restrict when you can use match.

(Lambdas already have that problem, but there it's not so bad because you can always use a named function. In this case, you would have to fall back to if/else chains.)

Why?