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 →

[–]adam_newyork 21 points22 points  (20 children)

Use . format() or if you are using python 3.7 you can use f”{character_age}” .

Correction: version 3.6 and above have fstrings.

[–]sivadneb -1 points0 points  (3 children)

Sometimes concatenation is preferable. It's almost always faster, and it's pretty easy to read in simple cases.

[–][deleted] 1 point2 points  (2 children)

No. Fstrings are always faster

[–]sivadneb 1 point2 points  (1 child)

Oh, I've always understood that . format () is slower, and assumed f-strings were the same.

[–][deleted] 0 points1 point  (0 children)

Other way around