On Wed, Oct 21, 2020 at 10:39 AM Steven D'Aprano <steve@pearwood.info> wrote:
The f-string has to be a literal - it's not a magic object that you can assign to and new locals appear.
Well, no, it's not an object at all, but surely "you can assign to and new locals appear" is the whole point of the feature? You assign to the f-string and it matches values from the string on the right hand side to create new locals, or over-write existing ones.
f"{name}: {value:d}" = "eleventytwo: 112"
will have the side effect of binding:
name = "eleventytwo" value = 112
Yes. It's *not an object*. The "spooky action at a distance" thing that I was responding to can't be an issue because the assignment is right there. Please, don't make me repeat all the same arguments again. Read the existing thread. ChrisA