mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
String method cleanup.
This commit is contained in:
parent
c8c6aa201f
commit
6e025bcde8
5 changed files with 7 additions and 13 deletions
|
@ -85,7 +85,6 @@ This module also defines an exception 'error'.
|
|||
|
||||
|
||||
import sys
|
||||
import string
|
||||
from pcre import *
|
||||
|
||||
#
|
||||
|
@ -223,10 +222,9 @@ def escape(pattern):
|
|||
|
||||
"""
|
||||
result = list(pattern)
|
||||
alphanum=string.letters+'_'+string.digits
|
||||
for i in range(len(pattern)):
|
||||
char = pattern[i]
|
||||
if char not in alphanum:
|
||||
if not char.isalnum():
|
||||
if char=='\000': result[i] = '\\000'
|
||||
else: result[i] = '\\'+char
|
||||
return ''.join(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue