News for hackers. Stuff that matters.
Re:PEP 701 – Syntactic formalization of f-strings by Demiurge on Tuesday February 13, 2024 @09:23AM (#39357854)
I just don't understand why everyone loves f-string so much. I do understand they might be better than + op? Perhaps. I've always liked .format method. You separate your template from your input data, and you can choose when the interpolation or execution takes place. You can re-use your template. It's a few more letters to type, but does not require complicated grammar extensions.

I would continue to use .format, but all my teammates are converting everything to fstrings, and I think my cognitive load is much higher because of it.

Re:PEP 701 – Syntactic formalization of f-strings by nightlyherb on Tuesday February 13, 2024 @10:01AM (#39358204)
Most of my use cases for string interpolation doesn't involve the concept of templates, so for me embedding the "data" inside the "template" is easier to read most of the time. Perhaps it's because the data and the "slots inside the template" are colocated? I had prefered keywords when `str.format` expression gets long anyway, so I guess I might not be the best person to judge.
Re:PEP 701 – Syntactic formalization of f-strings by lewiscollard on Tuesday February 13, 2024 @03:26PM (#39362403)
I understand this. Some part of me also resisted them until I worked out that, if used consistently, they _entirely_ eliminate format string bugs (of the "a user-supplied string contains string formatting characters" variety). And then I was a convert!
Re:PEP 701 – Syntactic formalization of f-strings by spdustin on Tuesday February 13, 2024 @05:02PM (#39363448)
For true "template" cases, I still use Template Strings (https://docs.python.org/3/library/string.html#template-strin...)