4 ms·
Please for the love of f"{deity}" don't do this. Making the language more complex, introducing p-string, just because people sometimes forget the f prefix? And
by roelschroeven 6y ago
Please for the love of f"{deity}" don't do this. Making the language more complex, introducing p-string, just because people sometimes forget the f prefix? And they're not going to forget the p prefix?
I don't even like f-strings all that much. Sure, f'a = {a}' is nice and clean, but
f'sin(a) = {math.sin(a)}; cos(a) = {math.cos(a)}'
is IMHO worse than
'sin(a) = {}; cos(a) = {}'.format(
math.sin(a),
math.cos(a),
)
and it only gets worse for longer strings and/or more complex expressions. Python already had 3 ways of formatting strings (%, .format(), string.Template (which nobody uses)). Adding a 4th that IMHO is only a very small improvement over .format() and that only in a limited number of use cases, was not really worth the effort. What happened to "There should be one-- and preferably only one --obvious way to do it"?
But making f-strings the default is 1000 times worse. Trading one set of errors for another one, making the language unnecessarily more complex in the process. Blurring the line between a string and formatting a string. What happened to "Explicit is better than implicit"? Bah.