More flexible f-string parsing sounds like a mistake. The basic use case is fine:
f"Hello, {name}, how are you?"
But putting entire expressions in there sounds like going too far. So now you can do this:
f" something { my_dict["key"] } something else "
But why not the simpler approach (this is simper to read for both humans and machines):
value = my_dict["key"]
f" something {value} something else "
Heck, even this monstrosity is allowed:
f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}"
From TFA (emphasis mine):
> Expression components inside f-strings can now be any valid Python expression including backslashes, unicode escaped sequences, *multi-line expressions*, comments and strings reusing the same quote as the containing f-string.
Edit: I do appreciate that at least the parser will give out detailed error messages when something is wrong in a f-string.
In summary the winning argument was it's always possible to for users to write unreadable code if they want and generally Python does not implement language level arbitrary restrictions to stop this. So, the benefits of a well-defined f-string syntax that is logically consistent outweigh the possibility some users will choose not to follow best practise.
* Other Python implementations to correctly and confidently implement f-strings
* CPython to use its regular parser to parse f-strings rather than have a special sub-parser
* Lots of edge-cases with f-string syntax to work consistently
As you could have read in the discussion rather than a bad-faith comment of "they are doing this just for <bad thing>", obviously no one wants to put a lot of effort into something for it to not have any benefit at all.
Now try that example again, but make the string include 4 different keys from that dict. That's why it's useful.
This kind of interpolation has been available in many other languages for years. Sure, you can abuse it if you want to, but I've rarely seen it happen in real code.
> Expression components inside f-strings can now be any valid Python expression including backslashes, unicode escaped sequences, *multi-line expressions*, comments and strings reusing the same quote as the containing f-string.
Edit: I do appreciate that at least the parser will give out detailed error messages when something is wrong in a f-string.