btw, Python has had pattern matching for almost two years now: https://peps.python.org/pep-0622/
If you support Python 3.10+ you can do this far more cleanly.
If you support Python 3.10+ you can do this far more cleanly.
Also, Python requires explicit returns (unless we're in a lambda), so using a `match` statement for the above example would need multiple duplicate statements (either `return`, or assignment to a repeated variable name, or calling a repeated continuation (although that's less common, due to Python not eliminating tail calls), etc.). A chain of `elif` would also have that problem.