[Python-Dev] string.Template format enhancements (Re: Replacement for print in Python 3.0)
tanzer@swing.co.at
tanzer at swing.co.at
Tue Sep 6 16:18:42 CEST 2005
Nick Coghlan <ncoghlan at gmail.com> wrote:
> With the above changes, the following would work:
> "$1: $2".format("Number of bees", "0.5")
> And produce:
> "Number of bees: 0.5"
>
> When pre-compiling string.Templates, the keyword method is
> significantly clearer, but if the syntax was accessible through a
> string method, then being able to use positional arguments would
> be very handy.
As long as named arguments don't get lost, that's fine. I
often use templates stored in variables/passed around as
arguments, where the positional form is not clear at all:
template.format("Number of bees", "0.5")
--
Christian Tanzer http://www.c-tanzer.at/
More information about the Python-Dev
mailing list