New submission from Finn Mason <[email protected]>:
>>> 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 <[email protected]>
<https://bugs.python.org/issue44341>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com