New Python 3.0 string formatting - really necessary?

Giampaolo Rodola' gnewsg at
Fri Dec 19 17:13:34 CET 2008

On 19 Dic, 17:01, walterbyrd <walterb... at> wrote:
> I have not worked with Python enough to really know. But, it seems to
> me that more I look at python 3.0, the more I wonder if it isn't a
> step backwards.
> To me, it seems that this:
> print "%s=%d" % ('this',99)
> Is much easier, and faster, to type, and is also easier to read and
> understand. It also allows people to leverage their knowledge of C.
> This (if it's right) is much longer, and requires more special
> characters.
> print( "{0}={1}".format('this',99))
> Maybe it's worth all the extra trouble, and breaking backward
> compatibilty, and all. But, I never had the idea that the old way was
> all that big a problem. Of course, I could be wrong. Was the old way
> all that big of a problem?

You can use the old 2.x syntax also in Python 3.x:

Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win
Type "help", "copyright", "credits" or "license" for more information.
>>> print("%s=%d" % ('this',99))

--- Giampaolo

More information about the Python-list mailing list