๐ Modern Python
Pattern Matching (match/case)
Structural matching, new in Python 3.10.
match lets you dispatch on the shape of data, not just its value.
def describe(p):
match p:
case (0, 0):
return "origin"
case (x, 0):
return f"on x-axis at {x}"
case (0, y):
return f"on y-axis at {y}"
case _:
return "somewhere else"