]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#2650: Refactor re.escape to use enumerate().
authorEzio Melotti <ezio.melotti@gmail.com>
Fri, 25 Mar 2011 12:19:30 +0000 (14:19 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Fri, 25 Mar 2011 12:19:30 +0000 (14:19 +0200)
Lib/re.py

index 9bd913a68ddbcfa7ee07c0ad6a47ad6a3ce3cad0..309afef125bf57f1946d1e7a3669203c86ce4bc6 100644 (file)
--- 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"