Pattern Matching in Python(github.com) |
Pattern Matching in Python(github.com) |
Also wondering about the degenerate forms of fall through alternates, so it's a stack of code optionally run.
There is another link to c code switches and duffs device in hn recently
def http_error(status):
try:
return HTTP_STATUS_CODES[status]
except KeyError:
return "Something else"
Also, method polymorphism always seemed more powerful and intuitive to me than switch statements when the operation is something like: multiply(scalar, scalar)
multiply(vector, scalar)
multiply(matrix, scalar)I think the latter would help a lot with error handling in particular, not to mention defining protocols.