Python Tip #308 (of 365): Match tuple-like data by shape with match-case. >>> po...
Trey Hunner ๐ @treyhunner@mastodon.social
Python Tip #308 (of 365):
Match tuple-like data by shape with match-case.
>>> point = (3, 4)
>>> match point:
... case (x, y):
... print(f"2D point ({x}, {y})")
... case (x, y, z):
... print(f"3D point ({x}, {y}, {z})")
...
2D point (3, 4)
๐งต (1/3)