3 ms·
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 sepa
by Demiurge 3y ago
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.
- nightlyherb 3y agoMost 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.
- lewiscollard 3y agoI 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!
- spdustin 3y agoFor true "template" cases, I still use Template Strings (https://docs.python.org/3/library/string.html#template-strings https://docs.python.org/3/library/string.html#template-strin...)