diff options
Diffstat (limited to 'Cython/Plex')
-rw-r--r-- | Cython/Plex/Regexps.py | 10 | ||||
-rw-r--r-- | Cython/Plex/Traditional.py | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/Cython/Plex/Regexps.py b/Cython/Plex/Regexps.py index 56b3f9c48..41816c939 100644 --- a/Cython/Plex/Regexps.py +++ b/Cython/Plex/Regexps.py @@ -87,9 +87,7 @@ def CodeRanges(code_list): Given a list of codes as returned by chars_to_ranges, return an RE which will match a character in any of the ranges. """ - re_list = [] - for i in xrange(0, len(code_list), 2): - re_list.append(CodeRange(code_list[i], code_list[i + 1])) + re_list = [CodeRange(code_list[i], code_list[i + 1]) for i in range(0, len(code_list), 2)] return Alt(*re_list) @@ -307,8 +305,7 @@ class Seq(RE): def __init__(self, *re_list): nullable = 1 - for i in xrange(len(re_list)): - re = re_list[i] + for i, re in enumerate(re_list): self.check_re(i, re) nullable = nullable and re.nullable self.re_list = re_list @@ -332,12 +329,11 @@ class Seq(RE): else: s1 = initial_state n = len(re_list) - for i in xrange(n): + for i, re in enumerate(re_list): if i < n - 1: s2 = m.new_state() else: s2 = final_state - re = re_list[i] re.build_machine(m, s1, s2, match_bol, nocase) s1 = s2 match_bol = re.match_nl or (match_bol and re.nullable) diff --git a/Cython/Plex/Traditional.py b/Cython/Plex/Traditional.py index 2738d1118..ec7252dae 100644 --- a/Cython/Plex/Traditional.py +++ b/Cython/Plex/Traditional.py @@ -104,7 +104,7 @@ class REParser(object): if self.c == '-' and self.lookahead(1) != ']': self.next() c2 = self.get() - for a in xrange(ord(c1), ord(c2) + 1): + for a in range(ord(c1), ord(c2) + 1): char_list.append(chr(a)) else: char_list.append(c1) |