diff --git a/Lib/re.py b/Lib/re.py index 9bd913a68dd..309afef125b 100644 --- a/Lib/re.py +++ b/Lib/re.py @@ -223,8 +223,7 @@ def escape(pattern): if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) - for i in range(len(pattern)): - c = pattern[i] + for i, c in enumerate(pattern): if c not in alphanum: if c == "\000": s[i] = "\\000"