On Thu, Sep 17, 2020 at 8:33 PM Dennis Sweeney <sweeney.dennis650@gmail.com> wrote:
I was definitely not proposing "spooky action at a distance". My proposal is to existing f-strings as the `__setattr__` protocol is to the `__getattr__` protocol. The template would only ever be hard-coded inline during the f-string assignment. This is the same restriction that existing f-strings have. I am suggesting a syntactic construct where f-strings can be assignment targets, not suggesting to keep track of which strings were f-strings or overriding assignment or something silly like that.
Before f strings became a thing, str objects grew a format method. The format method then was made nicer to use using the new fstring syntax. I suggest, maybe, the better thing to do here would be to propose that str should grow a parse method, THEN sprinkle some sugar on the syntax to make parsing usable in the less paint-by-numbers way you describe. I think I would definitely use both if they existed (the parse method and the fstring assignment syntax). But it seems to me the first thing to do would be for str to grow a parse method. --- Ricky. "I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler