Comment by pansa2
Comment by pansa2 3 days ago
The real crime is the design of Python's pattern matching in the first place:
match status:
case 404:
return "Not found"
not_found = 404
match status:
case not_found:
return "Not found"
Everywhere else in the language, you can give a constant a name without changing the code's behaviour. But in this case, the two snippets are very different: the first checks for equality (`status == 404`) and the second performs an assignment (`not_found = status`).
That's destructuring, a feature not a bug. Same as it works in any functional language - and tremendously useful once you get the hang of it