Re:Python 3's F-Strings: An Improved String Formatting Syntax
by jon_richards on Thursday January 21, 2021 @10:44AM
(#25860038)
Yes, I was asked by a Junior if they should always use f strings now. There are still a couple situations where you need format, such as when you’re formatting a variable instead of a literal.
Also, shoutout to Template for untrusted strings. It’s surprisingly unknown. Most people suggest replace or a custom format function.
So:
Or, to just use the available locals to automatically fill that in for you: Or if you want both globals and locals with a preference for locals: