summaryrefslogtreecommitdiff
path: root/Lib/string.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-09-26 18:56:44 +0000
committerRaymond Hettinger <python@rcn.com>2004-09-26 18:56:44 +0000
commit1d68dddda4969631b04b6e8442baf91abb478550 (patch)
tree2b3f9943017c028ce930d11c2425de316d41664c /Lib/string.py
parent1371ef045a89f2299ec80822bce55cf0b15dd9d2 (diff)
downloadcpython-1d68dddda4969631b04b6e8442baf91abb478550.tar.gz
Make the regex pattern easier to read, understand, and modify
by factoring out the common prefix (the delimiter).
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 623eb0edab..7371c915a1 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -101,10 +101,12 @@ class _multimap:
class _TemplateMetaclass(type):
pattern = r"""
- (?P<escaped>%(delim)s{2}) | # Escape sequence of two delimiters
- %(delim)s(?P<named>%(id)s) | # delimiter and a Python identifier
- %(delim)s{(?P<braced>%(id)s)} | # delimiter and a braced identifier
- (?P<invalid>%(delim)s) # Other ill-formed delimiter exprs
+ %(delim)s(?:
+ (?P<escaped>%(delim)s) | # Escape sequence of two delimiters
+ (?P<named>%(id)s) | # delimiter and a Python identifier
+ {(?P<braced>%(id)s)} | # delimiter and a braced identifier
+ (?P<invalid>) # Other ill-formed delimiter exprs
+ )
"""
def __init__(cls, name, bases, dct):