Getting an “invalid syntax” when trying to perform string interpolation
I have recently been learning python 3 and I cannot get any examples involving string interpolation (formatting) to work.
I have recently been learning python 3 and I cannot get any examples involving string interpolation (formatting) to work.
I am using template strings to generate some files and I love the conciseness of the new f-strings for this purpose, for reducing my previous template code from something like this:
I’m using the .format()
a lot in my Python 3.5 projects, but I’m afraid that it will be deprecated during the next Python versions because of f-strings, the new kind of string literal.
I was reading this blog post on Python’s new f-strings and they seem really neat. However, I want to be able to load an f-string from a string or file.