On Fri, 18 Jun 2021, Serhiy Storchaka wrote:

18.06.21 00:22, Ben Rudiak-Gould пише:
Okay, slightly off-topic, but can we *please* allow

    [*chunk for chunk in list_of_lists]

some day. I think it was left out because some discussion concluded it
would be too confusing, which is ridiculous. I assumed it would work and
was confused to find that it didn't. It's blatantly inconsistent.

It was originally proposed in PEP 448 (Additional Unpacking
Generalizations) but was excluded after discussing.

The first rejected variation in the PEP look perfectly unambigous to me.

Only in a the second variation could there be multiple interpretations,
but nothing worse than the difference between

    f(x, y, z)
    f((x, y, z))

Suggested solution: require appropriate brackets or parentheses.
This would leave the left form in the second variation a syntax error.
but allow the right side the obvious interpretation.

If someone would like to "unpack into the arguments of the call to f",
that could then be an entirely separate discussion.

However,
Discarding the first variation because the second could be ambigous,
seems to me like a case of baby and bath water.

If we allow

   [*chunk for chunk in list_of_lists]

we should allow also

   [x, y for x in a]

But why ??

which would be equivalent to

   [a[0], y, a[1], y, a[2], y, ...]

I dont see that equivalence, what are you building it on ?

We already have

    [x, (y for x in a)]
    [(x, y) for x in a]

both meaning something else.

Try this instead:

    [*(x, y) for x in a]
=   [*(a[0], y), *(a[1], y), *(a[2], y), ...]
=   [a[0], y, a[1], y, a[2], y, ...]


        /Paul
_______________________________________________
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/6OCFBWLJR4HSPLUZQR3P22LWYTWHI2ZP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to