[issue2650] re.escape should not escape underscore

Lorenz Quack report at bugs.python.org
Mon Apr 28 19:24:28 CEST 2008


Lorenz Quack <don at amberfisharts.com> added the comment:

>> The loop in escape should really use enumerate 
>> instead of "for i in range(len(pattern))".
>
>It needs i to edit s[i].

enumerate(iterable) returns a tuple for each element in iterable
containing the index and the element itself.

I attached a patch using enumerate. The patch also uses a frozenset
rather than a dict for the special characters.

----------
nosy: +donlorenzo
Added file: http://bugs.python.org/file10130/re.patch

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


More information about the Python-bugs-list mailing list