On 9/17/2020 11:38 AM, Eric V. Smith wrote:
In general, there's no way to start with a format specifier string and
from it get the type of the object that it should be applied to. For
example, any string without %'s is a valid datetime format specifier
(of dubious value, but such is life). Perhaps a better example is
decimal vs. float. What if I want %.2f to return a decimal? Would that
just not be possible?
So I think you'd have to limit this to a small set of built-in types.
In general, I think overloading f-strings as assignment targets would
be confusing. But I've been wrong before.
Also, it only works with literals. I can easily see wanting to build up
the scanf-like string programatically. So that puts me at -1.
f-strings only being literals is to avoid code injection. There's no
such requirement with a scanf-like string that basically describes a
regex and some assignment targets.
Eric
_______________________________________________
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/FDLVCPRTQWC65WDVM2CNSG4DJI52RKHN/
Code of Conduct: http://python.org/psf/codeofconduct/