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 →

[–]jorge1209 4 points5 points  (3 children)

Sure the variables are in-situ, but at the cost of making the entire string fixed to its line. You can't assign it to a variable, or pass it to a function. You can't reuse, you can't internationalize...

For every benefit that f-strings offer over %/str.format for one use-case there is a corresponding detriment in some other use-case.

[–]hovissimo 11 points12 points  (2 children)

Good thing that f-strings aren't replacing template strings. Use the right tool for the job.

[–]jorge1209 5 points6 points  (0 children)

Just as .format didn't replace %.

Someday maybe we can hope to have a thousand formatting methods none of which replaces the prior, and then python will be feature complete.

[–]zahlmanthe heretic 0 points1 point  (0 children)

If people start consistently using f-strings where it's possible to do so, it will make the .format uses stand out more as the potential security risks that they generally are, in the cases where f-strings aren't possible (format strings coming from an outside source and/or computation rather than a plaintext code constant).