[Python-3000] String formating operations in python 3k
Jim Jewett
jimjjewett at gmail.com
Thu Apr 6 00:50:16 CEST 2006
On 4/4/06, Ian Bicking <ianb at colorstudy.com> wrote:
> Alex Martelli wrote:
> > As for the % operator, I never liked it -- either a builtin function,
> > or even better a method of string objects, is going to be much more
> > readable (and my preference would be to have it take optional
> > positional arguments, corresponding to {1}, {2}, etc, and optional
> > named arguments, corresponding to {name} &c).
>
> Note that if it takes keyword arguments, but doesn't take a single
> dictionary-like object (like % and string.Template.substitute do), then
> you lose any ability to use clever or interesting dictionary-like
> objects for substitution.
If "%" is replaced by a method, there is no reason not to have multiple methods.
";lasdf;lks{1} asdf {0} asfd".subst_seq(["a", "b", "C"])
"asdfs{a} asdf {b} asfd".subst_map(locals())
"asdlfkjaslfj{1}{a}{b}".format(16, a=18, b=19)
-jJ
More information about the Python-3000
mailing list