Hacker News new | ask | show | jobs
by isaacremuant 2593 days ago
Your example is not representative because you're using literals.

Your actual example would be:

    "My name is {name}, I'm {feet} tall and live in {location}.".format(name=name, location=location, feet=feet)
And with f-strings:

    f"My name is {name}, I'm {feet} tall and live in {location}."
f-strings is clearly more readable, concise and actually faster to run.
1 comments

The literals were just an example. And personally I find it more explicit, which is my original point.

If its faster to run, then fair enough.

Using your example, I think

"My name is {name}, I'm {feet} tall and live in {location}.".format(name="Bob", location="USA", feet=7)

is less explicit than

"My name is Bob, I'm 7 feet tall and live in USA."

and that last one is faster to run ;-)
Yes it is.