[New-bugs-announce] [issue44341] Conflict between re.match and match keyword
Finn Mason
report at bugs.python.org
Mon Jun 7 19:22:07 EDT 2021
New submission from Finn Mason <finnjavier08 at gmail.com>:
>>> import re
>>> re.match('str', 'str').group()
'str'
>>> match 'str':
... case 'str':
... print('match!')
...
match!
>>> from re import match
>>> match
<function re.match ...>
As the above example demonstrates, while re.match doesn't raise an error despite having a keyword name, importing re.match directly into __main__ replaces the keyword with the function. The obvious solution is to rename re.match, but this would break many, many pieces of code.
----------
components: Library (Lib), Regular Expressions
messages: 395295
nosy: ezio.melotti, finnjavier08, mrabarnett
priority: normal
severity: normal
status: open
title: Conflict between re.match and match keyword
type: behavior
versions: Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44341>
_______________________________________
More information about the New-bugs-announce
mailing list