#2650: Refactor re.escape to use enumerate().

This commit is contained in:
Ezio Melotti 2011-03-25 14:19:30 +02:00
parent 7b9e97b487
commit ebbf1e67a8

View file

@ -223,8 +223,7 @@ def escape(pattern):
if isinstance(pattern, str): if isinstance(pattern, str):
alphanum = _alphanum_str alphanum = _alphanum_str
s = list(pattern) s = list(pattern)
for i in range(len(pattern)): for i, c in enumerate(pattern):
c = pattern[i]
if c not in alphanum: if c not in alphanum:
if c == "\000": if c == "\000":
s[i] = "\\000" s[i] = "\\000"