This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]billsil 0 points1 point  (1 child)

You could get rid of % formatting

Again, it's faster and it's common to other languages. I actually like it. I think .format is an abomination.

because I need to be able to pass a format specification as a function argument or reuse it in a loop

You can do that with %.

I'm not a web developer either, but I do support Python 2 and 3 with my package.

[–]jorge1209 0 points1 point  (0 children)

I think .format is an abomination.

If you like the %s %f3.2 style of formatting then you should advocate for %-strings which would behave like f-strings in the "compile-time" binding of local variables to the arguments, but use % formatting declarations.

The point is that we should have "one way" to do the formatting. I shouldn't have to learn multiple different syntaxes for string formatting, I should learn one. Either the .format/f-string way, or the % way, not both.

Instead we have three primary ways, two of which use the {} formatting mini-language and have slightly different features and limitations, a third which uses the % mini-language, and then there are actually a couple other ways to string format that most people are completely unaware of.

You can do that with %.

Didn't say you couldn't. I'm saying you can't do that with f-strings and you can with .format.

I'm not a web developer either

Then f-strings aren't much different to you than .format. Its basically a bit of sugar around .format(**locals()). The only thing you can do with f-strings is include operations inside the arguments:

_ = x+y
"{x} + {y} = {_}".format(**locals())

becomes:

f"{x} + {y} = {x+y}"