[Python-Dev] Binary Operator for New-Style String Formatting

Eric Smith eric at trueblade.com
Sun Jun 21 23:40:09 CEST 2009


I'm against syntax for this, for all the reasons stated by others.

Jerry Chen wrote:
> Just one last note: I think my end goal here was to preserve the
> visual clarity and separation between format string and format
> parameters, as I much prefer:
> 
> "%s %s %s" % (1, 2, 3)
> 
> over
> 
> "{0} {1} {2}".format(1, 2, 3)

If it helps, in 3.1 and 2.7 this can be written as
"{} {} {}".format(1, 2, 3)
I'm not sure it helps for "visual clarity", but it definitely makes the 
typing easier for simple uses.

> The former is a style I've grown accustomed to, and if % is indeed
> being slated for removal in Python 3.2, then I will miss it sorely
> (or... just get over it).

I've basically come to accept that %-formatting can never go away, 
unfortunately. There are too many places where %-formatting is used, for 
example in logging Formatters. %-formatting either has to exist or it 
has to be emulated.

Although if anyone has any suggestions for migrating uses like that, I'm 
interested.

Eric.



More information about the Python-Dev mailing list