[Python-3000] str.format() -- poss. code or doc bug?

Mark Summerfield mark at qtrac.eu
Fri Nov 30 18:45:20 CET 2007


On 2007-11-30, Guido van Rossum wrote:
> On Nov 30, 2007 8:08 AM, Mark Summerfield <mark at qtrac.eu> wrote:
> > Your reply seems to imply that Python 3 will have 3 different and
> > overlapping ways of formatting strings: %, str.format(), and
> > string.Template. If that is the case, it seems like overkill to me:-)
>
> IMO string.Template is a dead experiment.

Does that mean it should be deprecated in the docs?

> My original plan was to get rid of % in favor of str.format(). This
> seems to have run into objections from folks who don't want to have to
> change their code. They have a point: when the string is not a
> literal, it's not possible for 2to3 to automatically convert x%y to a
> .format() call. So perhaps we should deprecate % formatting and get
> rid of it at some later time.

I just downloaded the most recent docs and they describe % under "Old
String Formatting Operations" and say "The formatting operations
described here are obsolete and may go away in future versions of
Python. Use the new String Formatting in new code."

So for new users, str.format() will be _the_ way.

Thanks!

-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu





More information about the Python-3000 mailing list