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.

Author rhettinger
Recipients eric.araujo, georg.brandl, nitupho, rhettinger
Date 2011-10-18.23:41:56
SpamBayes Score 9.0753434e-07
Marked as misclassified No
Message-id <1318981316.78.0.322710249861.issue13173@psf.upfronthosting.co.za>
In-reply-to
Content
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.'
History
Date User Action Args
2011-10-18 23:41:56rhettingersetrecipients: + rhettinger, georg.brandl, eric.araujo, nitupho
2011-10-18 23:41:56rhettingersetmessageid: <1318981316.78.0.322710249861.issue13173@psf.upfronthosting.co.za>
2011-10-18 23:41:56rhettingerlinkissue13173 messages
2011-10-18 23:41:56rhettingercreate