3 ms·
Those f-strings are awful: "embed expressions inside string literals"!? What kind of a maniac does that!?
by carapace 10y ago
Those f-strings are awful: "embed expressions inside string literals"!? What kind of a maniac does that!?
- OJFord 10y agoMy initial reaction was similar, though slightly tempered. However, at least for me, once you try to think about what it is that you're actually objecting to, there's nothing left when it's a language-feature and supported by your tooling. With that support, why's it worse than `'{}'.format(expr)`?
- carapace 10y ago> "when it's a language-feature and supported by your tooling" But those are two different things, and the former drives the latter, of necessity. We (humans, the core devs, draw your circle, it wasn't God nor aliens) chose to add this BS to the standard language. Now, everyone who wants to make tools that work with python have to be written to deal with this additional syntax-within-a-syntax. How does it look in the grammar? Pretty? Your linters, your type analyzers, your documentation tools, and whatever else, all have to be (re)written to deal with this. For what? What is the huge pain point with putting your expressions in the call to format() or even in the "logic" code? Mixing source code and string literals is just stupid. It's one more example of how Python 3 is drawing the stupid away from Python 2. As a 2 syntax partisan, I'm sad to see 3 degenerate, but at least 2 is still off the "innovators'" radar.
- OJFord 10y ago> those are two different things, and the former drives > the latter, of necessity Absolutely, I wasn't suggesting they were the same - I joined them with 'and'. > tools that work with python have to be written to deal > with this additional syntax-within-a-syntax That's the point though, it's not "syntax-within-a-syntax", any more than is, say, a `lambda` - it's just "the [new] syntax".
- carapace 10y agoUm, https://docs.python.org/3.6/reference/lexical_analysis.html#formatted-string-literals https://docs.python.org/3.6/reference/lexical_analysis.html#... It is a mess and I pity the fools who have to implement it.