_
score can be used as a variable name anywhere in Python, such as:
_ = 10
print(_)
However, it is not accepted here:
d = dict(john = 10, owen=12, jenny=13)
match d:
case {'john' : 10, 'jenny': _}:
print('does not work', _)
ERROR: print('does not work', _)
NameError: name '_' is not defined
Yet, perfectly fine to use as follows:
d = dict(john = 10, owen=12, jenny=13)
match d:
case {'john' : 10, 'jenny': a}:
print('does not work', a)
Why is _
not a valid variable name in new match in Python 3.10?