Пара примеров, чтобы было понятно:
Пример 1:
Код: Выделить всё
def make_point_2d(pt):
match pt:
case (x, y):
return Point2d(x, y)
case _:
raise TypeError("not a point we support")
Код: Выделить всё
match response.status:
case 200:
do_something(response.data)
case 301 | 302:
retry(response.location)
Код: Выделить всё
spouse = match name:
case "John":
"Jane"
case "David":
"Alice"
print(spouse)
Подробнее здесь: https://stackoverflow.com/questions/769 ... expression
Мобильная версия