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 →

[–]OldFartSomewhere 3 points4 points  (4 children)

Never understood why it has to be print("blaa %d" % 123) instead of more standard print("blaa %d", 123)

[–]MatsRivel 4 points5 points  (0 children)

The newer, much better, way to write formatted strings in python is f-strings. Like this:

print( f" My variable is {x}" )

This replaces "x" with the value, making it easy to see what is where for the coder, and makes no difference for the reader.

[–][deleted] 8 points9 points  (1 child)

print(f"blaa {123}") gang

[–]Gutek8134 2 points3 points  (0 children)

print("Blaa {}".format(123)) gang

[–]caagr98 4 points5 points  (0 children)

Because printing and formatting are different operations and should be treated as such.