I don't fully understand why the keyword match can be used as a variable or function name, unlike other keywords if, while, etc.?
>>> match "abc":
... case "abc":
... print('Hello!')
...
Hello!
>>> from re import match
>>> match('A', 'A Something A')
<re.Match object; span=(0, 1), match='A'>
>>> match = '????'
>>> match
'????'
>>> case = 'something'
>>> case
'something'
Per PEP 622, match and case are being added as "soft keywords", so they will remain valid identifiers:
This PEP is fully backwards compatible: the
matchandcasekeywords are proposed to be (and stay!) soft keywords, so their use as variable, function, class, module or attribute names is not impeded at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With