New submission from Gregory P. Smith <g...@krypto.org>:
A well known anti-pattern in Python is use of re.match when you meant to use re.search. re.fullmatch was added in 3.4 via https://bugs.python.org/issue16203 for similar reasons. re.prefixmatch would be similar: we want the re.match behavior, but want the code to be obvious about its intent. This documents the implicit ^ in the name. The goal would be to allow linters to ultimately flag re.match as the anti-pattern when in 3.10+ mode. Asking people to use re.prefixmatch or re.search instead. This would help avoid bugs where people mean re.search but write re.match. The implementation is trivial. This is **not** a decision to deprecate the widely used in 25 years worth of code's re.match name. That'd be painful and is unlikely to be worth doing without spreading it over a 8+ year timeline. ---------- components: Library (Lib) messages: 380928 nosy: gregory.p.smith priority: normal severity: normal stage: needs patch status: open title: Proposal: re.prefixmatch method (alias for re.match) type: enhancement versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42353> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com