News for hackers. Stuff that matters.
Re:Things to use in Python 3 by collyw on Wednesday May 15, 2019 @08:20AM (#19918658)
> It's way more explicit than having a placeholder and a value on completely different parts of the expression.

No its not.

Re:Things to use in Python 3 by majewsky on Wednesday May 15, 2019 @08:53AM (#19918880)

  "My name is {}, I'm {}'{}'' tall and live in {}".format(name, location, feet, inches)
This error is much better hidden than in the equivalent:

  f"My name is {name}, I'm {location}'{feet}'' tall and live in {inches}."
Re:Things to use in Python 3 by collyw on Wednesday May 15, 2019 @09:15AM (#19919043)
I did mention named parameters, you are using positional parameters to make your point. You don't even list the variables in your example. That seems pretty implicit to me.

I think this is more explicit:

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

Re:Things to use in Python 3 by isaacremuant on Wednesday May 15, 2019 @09:58AM (#19919410)
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.
Re:Things to use in Python 3 by collyw on Wednesday May 15, 2019 @10:08AM (#19919511)
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.

Re:Things to use in Python 3 by cecilpl2 on Wednesday May 15, 2019 @12:00PM (#19920702)
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."

Re:Things to use in Python 3 by ansonhoyt on Thursday May 23, 2019 @09:21AM (#19991486)
and that last one is faster to run ;-)
Re:Things to use in Python 3 by collyw on Thursday May 16, 2019 @03:13AM (#19926839)
Yes it is.