From: Ezio Melotti Date: Fri, 25 Mar 2011 12:19:30 +0000 (+0200) Subject: #2650: Refactor re.escape to use enumerate(). X-Git-Tag: v3.2.1b1~216^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ebbf1e67a8c56a79ee62280d32517e77b103bf8e;p=thirdparty%2FPython%2Fcpython.git #2650: Refactor re.escape to use enumerate(). --- diff --git a/Lib/re.py b/Lib/re.py index 9bd913a68ddb..309afef125bf 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"