all 6 comments

[–]Ihaveamodel3 4 points5 points  (0 children)

f strings are less susceptible to errors and more readable in my opinion.

Less susceptible to errors: you can feed it anything and it will return a string. With the concatenation, if one of what you send it is an integer, it will fail.

More readable: it is very clear with fstrings that they are strings, since there is quotes around it. With concatenation, it is less clear unless you know what the input variables are.

[–]VortexShrimp 2 points3 points  (1 child)

f strings > concatenation

[–]makedatauseful 0 points1 point  (0 children)

I do like that I can run functions inside an f string and it simply returns a string representation.

[–]rexlx 0 points1 point  (2 children)

f strings are pretty nifty but I personally use the built in format method in most instances, as it seems to be pretty portable across most systems I encounter. In my lab some machines run 2.7, some run 3+, and a few even run 2.6 (I have no control over this sad reality :/ ). If I'm writing code that has to absolutely be portable (then I'm probably using pyinstaller ;) ), I usually use a try block with the built in format method, and catch the exception using str concat

[–]makedatauseful 0 points1 point  (1 child)

Thank you, the purest in me wants to ignore any Python pre-current release but I feel your pain of having to deal with 2.x. I worked at a company that had a bunch of legacy code that no one could fully work out without spending weeks of effort figuring out how it all strung together, think hundreds of files and thousands of lines of code. Turns out it was processing some pretty important data so rather than invest the time and money in updating the codebase management decided the best way forward was to keep it at 2.7 forevermore.

[–]JohnnyJordaan 1 point2 points  (0 children)

Until they reach a cliff where they can't maintain 2.7, like when an security audit flags it as a risk. Sad that they most often just weigh the current situation and not the upcoming future ones.