Skip to content

Commit 7d69da2

Browse files
refactoring code with For Else
refactoring code with For Else which is more pythonic, concise and efficient; how do you think this change which has practical value?
1 parent f7cab6f commit 7d69da2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

html5lib/_ihatexml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ def charStringToList(chars):
104104
charRanges = [item.strip() for item in chars.split(" | ")]
105105
rv = []
106106
for item in charRanges:
107-
foundMatch = False
107+
108108
for regexp in (reChar, reCharRange):
109109
match = regexp.match(item)
110110
if match is not None:
111111
rv.append([hexToInt(item) for item in match.groups()])
112112
if len(rv[-1]) == 1:
113113
rv[-1] = rv[-1] * 2
114-
foundMatch = True
114+
115115
break
116-
if not foundMatch:
116+
else:
117117
assert len(item) == 1
118118

119119
rv.append([ord(item)] * 2)

0 commit comments

Comments
 (0)