[issue2650] re.escape should not escape underscore

Alexander Belopolsky report at bugs.python.org
Thu May 8 18:12:29 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Thu, May 8, 2008 at 11:45 AM, Russ Cox <report at bugs.python.org> wrote:
..
>  My argument is only that Python should behave the same in
>  this respect as other systems that use substantially the same
>  regular expressions.
>

This is not enough to justify the change in my view.  After all, "A
Foolish Consistency is the Hobgoblin of Little Minds"
<http://www.python.org/dev/peps/pep-0008/>.

I don't know if there is much code out there that relies on the
current behavior, but technically speaking, this is an incompatible
change.  A backward compatible way to add your desired functionality
would be to add the "escape_special" function, but not every useful
3-line function belongs to stdlib.

This said, I would prefer simply adding '_' to _alphanum over _special
approach, but still -1 on the whole idea.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2650>
__________________________________


More information about the Python-bugs-list mailing list