3 ms·
I know this is just a personal feeling, but I prefer paying the cost of writing f every time to have an indicator of where I'm expecting substitutions, rather t
by Traster 7y ago
I know this is just a personal feeling, but I prefer paying the cost of writing f every time to have an indicator of where I'm expecting substitutions, rather than having the default behaviour of the language be that they're going to interfere with your string literals. It just feels like doing something non-obvious by default is more likely to cause issues, whereas the person forgetting the f in an f-string clearly knows about f-strings and so is going to find their error much more easily. Having said that, I'm not a someone who writes particularly pythonesque code in the first place so my sensibilities don't carry a huge amount of weight.
- ChrisSD 7y agoTalking of probably unpopular opinions: I'd prefer that all strings be raw by default so escape characters aren't processed at all. Characters like `\n` or `\uXXXX` can be useful sometimes but I'd prefer to opt in to that. In fact, with f-strings its easy to simple use a constant instead of `\` escape sequences. Admittedly this would be too big of a change to make now.
- mantap 7y agoI think the way it works now is correct. Using escape characters is more common than writing strings with backslashes. The more common case should be default.
- abstractbeliefs 7y agoI feel similarly. I'm unsure where such a drive is coming from. I know it's just a philosophy, but the whole "explicit is better than implicit" thing stands to test here, and it looks like Python could deviate from it yet again. Likewise, "there should be only one way to do something". Now we have "%s"%somevalue, "".format(), and f"". I can't help but feel that .format() is the right option, being clear, flexible, explicit, and unambiguous.