Issue
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'
Solution
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
match
andcase
keywords are proposed to be (and stay!) soft keywords, so their use as variable, function, class, module or attribute names is not impeded at all.
Answered By - Brian Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.