2 ms·
> Where, with f strings, you'd need to do some nasty escaping or create descriptive labels for the substitutions that were previously unnecessary. No, with f-s
by dragonwriter 7y ago
> Where, with f strings, you'd need to do some nasty escaping or create descriptive labels for the substitutions that were previously unnecessary.
No, with f-strings, you'd have to take the expressions you use in the call to format and stick them between the curly braces, and trade the .format(...) after the string for an f before it.
f-strings are almost without exception more terse than .format for single-use formatted strings.
- pydry 7y agoIt would be shorter if you stuck those expressions in between the curly braces, and it would break as soon as quotation marks are introduced. I guess it's a you don't use those too often in your expressions? If would be longer if you started attaching descriptive names to those expressions and using them in an f string.