Matthew Suozzo <matthew.suo...@gmail.com> added the comment:

> It just won't work unless you add explicit ".*" or ".*?" at the start of the 
> pattern

But think of when regexes are used for validating input. Getting it to "just 
work" may be over-permissive validation that only actually checks the beginning 
of the input. They're one missed test case away from a crash or, worse, a 
security issue.

This proposed name change would help make the function behavior obvious at the 
callsite. In the validator example, calling "prefixmatch" would stand out as 
wrong to even the most oblivious, documentation-averse user.

> My point is that re.match is a common bug when people really want re.search.

While I think better distinguishing the interfaces is a nice-to-have for 
usability, I think it has more absolute benefit to correctness. Again, 
confusion around the semantics of "match" were the motivation for adding 
"fullmatch" in the first place but that change only went so far to address the 
problem: It's still too easy to misuse the existing "match" interface and it's 
not realistic to remove it from the language. A new name would eliminate this 
class of error at a very low cost.

----------
nosy: +matthew.suozzo

_______________________________________
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

Reply via email to