Hurray! It’s Christmas time – and Python 3.6 has been released!
One of the many goodies packed into the new release are formatted string literals, or simply called “f-strings”. In this blog post I’ll explain why this is good news.
First, they are called f-strings because you need to prefix a string with the letter “f” in order to get an f-string, similar to how you create a raw string by prefixing it with “r”, or you can use the prefixes “b” and “u” to designate byte strings and unicode strings. Note that the “u” prefix was only necessary in Python 2 (“Legacy Python”), since native strings are the default now in Python 3.
The letter “f” also indicates that these strings are used for formatting. Now Python already provides several ways for formatting strings, so you may wonder why the Python gods introduced yet another way, in blatant violation of the Zen