diff options
author | Barry Warsaw <barry@python.org> | 2017-09-04 20:32:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 20:32:10 (GMT) |
commit | ba4279683f8eb8f59be10d12547ea89480614388 (patch) | |
tree | a04e6ac5d0855275d27308072b05c7635423ed9e /Doc | |
parent | f9f17346d722b6f073a048b41ec0d6adf336d1d2 (diff) | |
download | cpython-ba4279683f8eb8f59be10d12547ea89480614388.zip cpython-ba4279683f8eb8f59be10d12547ea89480614388.tar.gz cpython-ba4279683f8eb8f59be10d12547ea89480614388.tar.bz2 |
bpo-1198569: Allow string.Template braced pattern to be different (#3288)
* bpo-1198569: Allow the braced pattern to be different
``string.Template`` subclasses can optionally define ``braceidpattern`` if
they want to specify different placeholder patterns inside and outside the
braces. If None (the default) it falls back to ``idpattern``.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/string.rst | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 8176a81..1a9b630 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -754,9 +754,21 @@ attributes: be set in the subclass's class namespace). * *idpattern* -- This is the regular expression describing the pattern for - non-braced placeholders (the braces will be added automatically as - appropriate). The default value is the regular expression - ``[_a-z][_a-z0-9]*``. + non-braced placeholders. The default value is the regular expression + ``[_a-z][_a-z0-9]*``. If this is given and *braceidpattern* is ``None`` + this pattern will also apply to braced placeholders. + + .. versionchanged:: 3.7 + *braceidpattern* can be used to define separate patterns used inside and + outside the braces. + +* *braceidpattern* -- This is like *idpattern* but describes the pattern for + braced placeholders. Defaults to ``None`` which means to fall back to + *idpattern* (i.e. the same pattern is used both inside and outside braces). + If given, this allows you to define different patterns for braced and + unbraced placeholders. + + .. versionadded:: 3.7 * *flags* -- The regular expression flags that will be applied when compiling the regular expression used for recognizing substitutions. The default value |