classification
Title: string.Template not flexible enough to subclass (regexes)
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: barry Nosy List: ajaksu2, barry, ianbicking
Priority: normal Keywords:

Created on 2005-05-09 20:55 by ianbicking, last changed 2010-08-21 14:31 by BreamoreBoy.

Messages (2)
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:

http://svn.colorstudy.com/home/ianb/recipes/sub_expr.py

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) Date: 2009-02-16 01:01
IIUC, Ian's link has a doctest for this feature.
History
Date User Action Args
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