I tried to replace an if/elif/elif/.../else code block with the shorter match/case
from Python 3.10.
I have three constants defined and want to do something different for each one, so my code looks roughly like this:
>>> const_a = 1
>>> const_b = 2
>>> const_c = 3
>>> interface = const_b # example
>>> match interface:
... case const_a:
... print("case a")
... case const_b:
... print("case b")
... case const_c:
... print("case c")
However, when running this code, there will be an Exception:
File "<stdin>", line 2
SyntaxError: name capture 'const_a' makes remaining patterns unreachable
What am I doing wrong?