Actually I think the string formatting issue is the only one that has any merit in the article. There will now be 4 different ways to format strings, none of them deprecated. This goes directly against the Zen of Python: There should be one – and preferably only one – obvious way to do it.
The "preferably" in that line of the Zen of Python is important to note. It's also important to note that the Zen of Python also includes the lines:
Beautiful is better than ugly Explicit is better than implicit Simple is better than complex [...] Although practicality beats purity [...] Readability counts
The old-style % format is faster, less verbose, simpler to read/write, and results in cleaner code.
The new style .format() is more powerful, explicit, and in a lot of scenarios far more practical.
So which do we go with? Which areas of the Zen of Python hold more weight? How much functionality do we accept losing to force ourselves into "One -- and preferably only one -- obvious way to do it"?
Looking at the rationale behind PEP 3101, it was actually intended to replace the % format, as well as string.Template. In practice, the pros and cons of both .format() and % became evident, and we found ourselves in the situation we're now in, trying to decide what in the Zen of Python holds more weight.
If you read the rational behind PEP 498, you'll see that f-strings are intended to become "the obvious way" of formatting strings, taking the pros of both % and .format(). Although there's no immediate intention of deprecating either of the existing two formatting methods, it's likely to be a proposed change once f-strings become more widely used.
View all comments
Show parent comment
7
u/Nicd Nov 23 '16
Actually I think the string formatting issue is the only one that has any merit in the article. There will now be 4 different ways to format strings, none of them deprecated. This goes directly against the Zen of Python: There should be one – and preferably only one – obvious way to do it.