Message145876
This looks like a reasonable use case. That being said, I question whether the defaults should be attached directly to the template instance or whether they should be part of the substitution method.
FWIW, there already have a couple of other ways to do it:
>>> from string import Template
>>> s = Template("${user} made me a ${flavor} cake.")
>>> default = {"user":"Dennis"}
>>> s.substitute(default, flavor='vanilla')
'Dennis made me a vanilla cake.'
>>> s.substitute(default, user='Ken', flavor='vanilla')
'Ken made me a vanilla cake.'
>>> from collections import ChainMap
>>> s.substitute(ChainMap(dict(flavor='vanilla'), default))
'Dennis made me a vanilla cake.' |
|
Date |
User |
Action |
Args |
2011-10-18 23:41:56 | rhettinger | set | recipients:
+ rhettinger, georg.brandl, eric.araujo, nitupho |
2011-10-18 23:41:56 | rhettinger | set | messageid: <1318981316.78.0.322710249861.issue13173@psf.upfronthosting.co.za> |
2011-10-18 23:41:56 | rhettinger | link | issue13173 messages |
2011-10-18 23:41:56 | rhettinger | create | |
|