One of the best blog-type Python resources on the web has just boggled my mind by presenting a new, beautifully presented article on how to use a to-be-deprecated function that has bugs. Formally known as “Interpolation”, this string formatting system uses the “%” operator to define substitution and format options. Note that this use of the “%” operator has nothing to do with the modulo math operation where 18%5 yields 3 – the remainder left when dividing 15 by 5.
Interpolation is covered at the bottom of page 1 of the Formatting Options Toolbox but we note in the heading that while it is still the most widely (mis)used formatting tool, Python says it is to be deprecated due to bugs – as well as limitations – which are not present in the format FUNCTION or the format METHOD available as of 3.5.
Now lets take a professional step forward. Just as modern doctors no longer use leaches to bleed their patients, Python programmers no longer need to rely on buggy, limited formatting tools as they leave behind archaic versions of the language. Beginning with 3.6, a beautiful, complete, powerful (though a little complicated) formatting system called “f-strings” has emerged. This is a tool for a professional developer who demands respect and wants his or her work taken seriously.
I will grant that mastering f-strings takes a little work.
But what in this world that is worthwhile doesn’t?