![](https://secure.gravatar.com/avatar/d67ab5d94c2fed8ab6b727b62dc1b213.jpg?s=120&d=mm&r=g)
On Thu, Sep 17, 2020 at 11:02 PM Paul Moore <p.f.moore@gmail.com> wrote:
On Thu, 17 Sep 2020 at 13:38, Dennis Sweeney <sweeney.dennis650@gmail.com> wrote:
TL;DR: I propose the following behavior:
>>> s = "She turned me into a newt." >>> f"She turned me into a {animal}." = s >>> animal 'newt'
Something very similar to this already exists on PyPI: https://pypi.org/project/parse/
I don't have a strong opinion on whether it would be useful in the stdlib, other than to say that I've never personally used it, so it's not that significant a need for me.
I've frequently yearned for an sscanf-like feature in Python. Usually I end up longhanding it with string methods, or else reaching for a regex, but neither of those is quite what I want. I'd prefer scanf notation to format strings, but either is acceptable. Assigning to an f-string is VERY tempting. It doesn't quite sit right with me (f-strings feel like literals, even though they aren't, and it doesn't make sense to assign to a string literal) - but I do like the concept. If it existed in the language, I would definitely use it. That's not to say it should exist, but I would use it if it did :) ChrisA