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 barry
Recipients barry, eric.araujo, georg.brandl, nitupho, rhettinger, serhiy.storchaka
Date 2013-11-10.20:22:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384114941.56.0.439396428353.issue13173@psf.upfronthosting.co.za>
In-reply-to
Content
I'm looking at this issue again with an eye toward Python 3.4.

Raymond describes what I think is a reasonable way to use defaults:

>>> x = Template('$foo $bar')
>>> defaults = dict(foo='one', bar='two')
>>> x.substitute(defaults)
'one two'
>>> x.substitute(defaults, bar='three')
'one three'
>>> x.substitute(defaults, foo='nine', bar='three')
'nine three'

(The implementation actually uses ChainMap.)

Now, to address Bfontaine's complaint about passing around tuples, observe that Template instances are Just Instances, so you can always do this:

>>> x = Template('$foo $bar')
>>> x.defaults = defaults
>>> x.substitute(x.defaults, foo='nine', bar='three')
'nine three'

IOW, just stash your defaults on the instance and pass the instance around.  Does the Template class actually need more built-in support for defaults?  I'm inclined to close this as Won't Fix.
History
Date User Action Args
2013-11-10 20:22:21barrysetrecipients: + barry, georg.brandl, rhettinger, eric.araujo, nitupho, serhiy.storchaka
2013-11-10 20:22:21barrysetmessageid: <1384114941.56.0.439396428353.issue13173@psf.upfronthosting.co.za>
2013-11-10 20:22:21barrylinkissue13173 messages
2013-11-10 20:22:21barrycreate