What are the advantages of the specification syntax for the new Python 3 format over the old one used by the `%` operator?

Pep 3101 provides the rationale for finally replacing the % operator with the format method. This question and the accepted answer dwell on the same points.

I could not find, however, the rationale for the new syntax, and I do not understand the benefits of this change. Pep 3101 lists various alternative syntaxes that also include the famous printf format specifier style, as specified in the C99 standard, and its variants. (For an example with documentation, go here to section 7.19.6.1 "The fprintf Function" on pages 274ff).

For the new string.format() method, the use of the same format specification language used by the % operator was considered.

What can be done with the new syntax that could not be executed with the old?

Edit: parameter reordering could also be added to the old syntax just as it was added to the ANSI C standard. View the latest man sprintf

+8
python string formatting format-specifiers
source share

No one has answered this question yet.

See similar questions:

1311
String formatting:% vs .format
217
Why does Python "add" not "push"?

or similar:

941
What is the difference between old style and new style classes in Python?
801
What is the standard Python docstring format?
424
What are the benefits of NumPy over regular Python lists?
401
What is the most "pythonic" way to iterate over a list in pieces?
353
What is the general format of Python file headers?
184
In practice, what are the main uses of the new "exit" syntax in Python 3.3?
174
What is the python notation syntax .. ("dot dot")?
64
What is the advantage of the new print function in Python 3.x over the print operator of Python 2?
2
C # get NumberFormatInfo
one
Table matching old and new Python string formatting

All Articles