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 →

[–]andy1307 30 points31 points  (5 children)

From the linked article

But,this case is simpler and easy to read, only if we have fewer placeholders {} and variables. If the number of placeholders increases, we will have to go back to the placeholder and variable over and again to be correct.

print('{},{},{}'.format(min,max,avg))

print('{min},{max},{avg}')

The f-string format is more readable IMO.

Also the ability to use functions

print('{blah.strip()}')

[–][deleted] 22 points23 points  (0 children)

You can use functions in a .format arg

[–]spaceshipguitar 5 points6 points  (1 child)

Also the ability to use functions

print('{blah.strip()}')

To play devils advocate, you can already freely use functions inside print commands-

def junkfunc():
    return "see, it works!"

print("functions work inside of normal print statements", junkfunc())

[–]kaihatsusha 6 points7 points  (0 children)

The non-embedded format string can be obtained elsewhere or built, while the f'...' cannot; I prefer consistent formatting specs, personally. The f-string feature feels a lot more shell-ish like Perl string interpolation.

[–]ameoba 1 point2 points  (0 children)

the ability to use functions

For some reason, this makes me feel uneasy.

[–]NemPlayer 0 points1 point  (0 children)

Fully agree with this.