Barry A. Warsaw added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13173>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com