Hacker News new | past | comments | ask | show | jobs | submit login

Also not a fan. The two existing methods of string formatting are sufficient:

    "%s %s %s" % (a, b, a)
    "{} {} {}".format(a, b, a)
If you want placeholders to match variable names, you can do:

    "{a} {b} {a}".format(a=a, b=b)
    "{a} {b} {a}".format(**locals())
So this is just unnecessary (especially since the "f" prefix is easier to miss than a "format" method):

    f"{a} {b} {a}"
And this is downright obfuscated—putting operators inside of string literals:

    f"{a + ' ' + b + ' ' + a}"



I certainly agree about your last statement, I have no clue what that would do without reading the spec. I'd guess an error, but apparently not.


The PEP says that locals() and globals() solutions were considered, and discarded:

https://www.python.org/dev/peps/pep-0498/#no-use-of-globals-...

You could argue that's not a good enough reason, but it's there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: