
July 23, 2015
7:57 p.m.
On Fri, Jul 24, 2015 at 3:52 AM, Ron Adam <ron3200@gmail.com> wrote:
The part that bothers me is it seems like the "f" should be a unary operator rather than a string prefix.
As a prefix:
s = f'{spam}{{eggs}}' # spam s2 = s.format(eggs=eggs) # eggs
As an unary operator:
s = ? '{spam}{{eggs}}' # spam s2 = ? s # eggs
(? == some to be determined symbol)
They are just normal strings in the second case.
Except that they can't be normal strings, because the compiler has to parse them. They're expressions. You can't take input from a user and f-string it (short of using exec/eval, of course); it has to be there in the source code. ChrisA