This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: string.Template not flexible enough to subclass (regexes)
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: ajaksu2, barry, ianbicking
Priority: normal Keywords:

Created on 2005-05-09 20:55 by ianbicking, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3288 merged barry, 2017-09-04 18:14
PR 3303 merged barry, 2017-09-04 20:48
Messages (7)
msg54520 - (view) Author: Ian Bicking (ianbicking) * Date: 2005-05-09 20:55
The regular expressions in string.Template can be
overidden, but there's not an easy way to override the
expression for variables inside braces and to a
different expression than variables not in braces. 
E.g., you might allow full expressions in braces
(including arbitrary punctuation), but only normal
variable names outside.  An example of using this kind
of technique:

So, in summary, idpattern should be split into two,
idpattern and bracepattern.  (Maybe a default of None
for bracepattern, and use idpattern if bracepattern is
None -- this would be backward compatible so that
overriding only idpattern will effect both)
msg82198 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-16 01:01
IIUC, Ian's link has a doctest for this feature.
msg202569 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2013-11-10 20:30
This seems like a reasonable request.  Do you care to submit a patch with tests and doc updates?
msg301226 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-09-04 17:12
Sorry for the long delay.  It looks like Ian's original link is no longer valid.  Do you have an updated link to a possible doctest or example?
msg301249 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-09-04 19:49
Never mind; I crafted a decent test for the PR.
msg301256 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-09-04 20:32
New changeset ba4279683f8eb8f59be10d12547ea89480614388 by Barry Warsaw in branch 'master':
bpo-1198569: Allow string.Template braced pattern to be different (#3288)
msg301267 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-09-04 21:29
New changeset 973b901212bd84d279904bab6654709f4ec32470 by Barry Warsaw in branch 'master':
What's New for bpo-1198569 (#3303)
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41966
2017-09-04 21:29:28barrysetmessages: + msg301267
2017-09-04 20:48:09barrysetpull_requests: + pull_request3334
2017-09-04 20:33:00barrysetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2017-09-04 20:32:12barrysetmessages: + msg301256
2017-09-04 19:49:26barrysetmessages: + msg301249
2017-09-04 18:14:47barrysetpull_requests: + pull_request3326
2017-09-04 17:12:17barrysetversions: + Python 3.7, - Python 3.2
2017-09-04 17:12:12barrysetmessages: + msg301226
2013-11-10 20:30:34barrysetmessages: + msg202569
2010-08-21 14:31:52BreamoreBoysetversions: + Python 3.2, - Python 2.7
2009-02-16 01:01:51ajaksu2setnosy: + ajaksu2
stage: needs patch
messages: + msg82198
versions: + Python 2.7
2005-05-09 20:55:25ianbickingcreate