[Python-ideas] One way to do format and print

Sven R. Kunze srkunze at mail.de
Wed Sep 9 18:05:10 CEST 2015

On 09.09.2015 02:09, Andrew Barnert via Python-ideas wrote:
> I think it's already been established why % formatting is not going away any time soon.
> As for de-emphasizing it, I think that's already done pretty well in the current docs. The tutorial has a nice long introduction to str.format, a one-paragraph section on "old string formatting" with a single %5.3f example, and a one-sentence mention of Template. The stdtypes chapter in the library reference explains the difference between the two in a way that makes format sound more attractive for novices, and then has details on each one as appropriate. What else should be done?

I had difficulties to find what you mean by tutorial. But hey, being a 
Python user for years and not knowing where the official tutorial resides...

Anyway, Google presented me the version 2.7 of the tutorial. Thus, the 
link to the stdtypes documentation does not exhibit the note of, say, 3.5:

"Note: The formatting operations described here exhibit a variety of 
quirks that lead to a number of common errors (such as failing to 
display tuples and dictionaries correctly). Using the newer str.format() 
interface helps avoid these errors, and also provides a generally more 
powerful, flexible and extensible approach to formatting text."

So, adding it to the 2.7 docs would be a start.

I still don't understand what's wrong with deprecating %, but okay. I 
think f-strings will push {} to wide-range adoption.


More information about the Python-ideas mailing list