3 ms·
You're correct about JavaScript. I forgot about the backticks. Thank you for the explanation of the f-strings. I'm pretty sure that migrating old strings to "\
by pmontra 7y ago
You're correct about JavaScript. I forgot about the backticks.
Thank you for the explanation of the f-strings. I'm pretty sure that migrating old strings to "\{x\}" could be automated but we can't force everybody to migrate their code. There is probably no other way than the one they followed.
- Dylan16807 7y agoIt's also just safer. You want your default string type to have as few gotchas about what can be put in it as possible.
- duckerude 7y ago"\{x\}" includes the backslashes into the string literally. So even if that worked for f-strings it would change the meaning for older Python versions. Requiring people to update common old code is also just something to avoid unless necessary. The correct way to escape braces in f-strings is with double braces, so f"{{x}}". This is consistent with the way str.format works. f-string syntax is very similar to str.format syntax in general.