match x:
case -0j:
y = 0
match x:
case bytes(z):
y = 0
match x:
case 0 if 0:
y = 0
case 0 if 1:
y = 1
match 3:
case 0 | 1 | 2 | 3:
x = True
match x:
case [0, 1] | [1, 0]:
y = 0
match x:
case [*_]:
return "seq"
case {}:
return "map"
match x:
case {0: [1, 2, {}]}:
y = 0
case {0: [1, 2, {}] | True} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}:
y = 1
case []:
y = 2
match x:
case 0.25 + 1.75j:
y = 0
match x:
case -0j:
y = 0
match 4:
case 0 | 1 | 2 | 3:
x = True
match x:
case 0 if x:
y = 0
match x:
case {1: 0}:
y = 0
case {0: 0}:
y = 1
case {**z}:
y = 2
match Seq():
case [*_]:
y = 0
match x:
case 1:
y = 0
case 1:
y = 1
match x:
case {"foo": bar}:
y = bar
match (0, 1, 2):
case [0, 1, *x, 2]:
y = 0
match x:
case [0]:
y = 0
case [1, 0] if (x := x[:0]):
y = 1
case [1, 0]:
y = 2
match w:
case [x, y, *_]:
z = 0
match x:
case -0.25 - 1.75j:
y = 0
match (x,):
case [y]:
z = 0
match x:
case A.B.C.D:
y = 0
match x:
case None:
y = 0
match x:
case 0:
y = 0
match x:
case False:
y = 0
match x:
case []:
y = 0
case [""]:
y = 1
case "":
y = 2
match x:
case z:
y = 0
match w:
case [x, y, *rest]:
z = 0
match x:
case (0 as z) | (1 as z) | (2 as z) if z == x % 2:
y = 0
match x:
case {0: [1, 2, {}]}:
y = 0
case {0: [1, 2, {}] | False} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}:
y = 1
case []:
y = 2
match (0, 1, 2):
case 0, *x:
y = 0
match (0, 1, 2):
case *x, 2,:
y = 0
match x,:
case y,:
z = 0
match w, x:
case y, z:
v = 0
match w := x,:
case y as v,:
z = 0
match x:
case f"{y}":
pass
match {"test": 1}:
case {
**rest,
}:
print(rest)
match {"label": "test"}:
case {
"label": str() | None as label,
}:
print(label)
match x:
case [0, 1,]:
y = 0
match x:
case (0, 1,):
y = 0
match x:
case (0,):
y = 0
match x,:
case z:
pass
match x, y:
case z:
pass
match x, y,:
case z:
pass
match x:
case None:
...
case True:
...
case False:
...
match x:
case a.b:
...
case a.b.c:
...
case '':
...
case b'':
...
case 1:
...
case 1.0:
...
case 1.0J:
...
case 1 + 1j:
...
case -1:
...
case -1.:
...
case -0b01:
...
case (1):
...
match x:
case 1 | 2:
...
case '' | 1.1 | -1 | 1 + 1j | a.b:
...
match x:
case a:
...
match x:
case a as b:
...
match x:
case 1 | 2 as two:
...
case 1 + 3j as sum:
...
case a.b as ab:
...
case _ as x:
...
match x:
case _:
...
match x:
case 1, 2, 3:
...
case (1, 2, 3,):
...
case (1 + 2j, a, None, a.b):
...
case (1 as X, b) as S:
...
case [1, 2, 3 + 1j]:
...
case ([1,2], 3):
...
case [1]:
...
match x:
case *a,:
...
case *_,:
...
case [1, 2, *rest]:
...
case (*_, 1, 2):
...
match x:
case Point():
...
case a.b.Point():
...
case Point2D(x=0):
...
case Point2D(x=0, y=0,):
...
case Point2D(0, 1):
...
case Point2D([0, 1], y=1):
...
case Point2D(x=[0, 1], y=1):
...
match x := b:
case {1: _}:
...
case {'': a, None: (1, 2), **rest}:
...
match y:
case a if b := c: ...
case e if 1 < 2: ...
match *a + b, c match *(a + b), c match (*a + b, c) match -a * b + c match -(a * b) + c match (-a) * b + c match ().a match (()).a match ((),).a match [a].b match [a,].b match [(a,)].b match()[a:
b] if match := 1: pass
match match:
case 1: pass
case 2:
pass
match = lambda query: query == event
print(match(12))