On Thu, Sep 17, 2020 at 11:02 PM Paul Moore <p.f.mo...@gmail.com> wrote:
>
> On Thu, 17 Sep 2020 at 13:38, Dennis Sweeney
> <sweeney.dennis...@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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/65QIQN6VHX3TJIMCBXCZHAWBKA2V54WG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to