On Fri, Sep 18, 2020, 6:35 AM Alex Hall <alex.moj...@gmail.com> wrote:

> The point is that this:
>

>     (a, b) = c
>
> is 'assigning to a literal' just as much as this:
>
>     f"{a} {b}" = c
>
> Both are just things that look like expressions with dynamic values but
> aren't.
>

I agree with you. It's not that whacky in principle. But it still looks
very odd.

One reason might be because there's "stuff" inside the fstring that isn't
getting assigned to (str characters). Tuple assignment syntax doesn't have
that extra stuff.

Why not just grow a parse method on str that returns a dict and do it this
way?

q = "{a} {b}"
p = "1 2"
(a, b) = q.parse(p)

Or with the q template string literal:

(a, b) = "{a} {b}".parse(p)

Yes you write the a and b twice, just as with the format method:

p = "{a} {b}".format(a=1, b=2)

My point is that for symmetry of usability, if you're going to have the f
string assignment syntax you should have a template str parse method too.
And the parse method should be decided on first.
_______________________________________________
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/XULHNCOO3DKCKYTQGPDOVNG6IXFKKW37/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to