mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
#2650: Refactor re.escape to use enumerate().
This commit is contained in:
parent
7b9e97b487
commit
ebbf1e67a8
1 changed files with 1 additions and 2 deletions
|
@ -223,8 +223,7 @@ def escape(pattern):
|
||||||
if isinstance(pattern, str):
|
if isinstance(pattern, str):
|
||||||
alphanum = _alphanum_str
|
alphanum = _alphanum_str
|
||||||
s = list(pattern)
|
s = list(pattern)
|
||||||
for i in range(len(pattern)):
|
for i, c in enumerate(pattern):
|
||||||
c = pattern[i]
|
|
||||||
if c not in alphanum:
|
if c not in alphanum:
|
||||||
if c == "\000":
|
if c == "\000":
|
||||||
s[i] = "\\000"
|
s[i] = "\\000"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue