#2650: Refactor re.escape and its tests.
diff --git a/Lib/re.py b/Lib/re.py
index 955b6b5..6a01743 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -207,8 +207,7 @@
     "Escape all non-alphanumeric characters in pattern."
     s = list(pattern)
     alphanum = _alphanum
-    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"