On Sat, Oct 15, 2016 at 1:49 PM Steven D'Aprano <st...@pearwood.info> wrote:

> And the transformation of *t for the items of t (I don't care if it is a
> real transformation in the implementation, or only a fictional
> transformation) cannot work in a list comp. Let's make the number of
> items of t explicit so we don't have to worry about variable item
> counts:
>     [*t for t in iterable]  # t has three items
>     [a, b, c for (a, b, c) in iterable]
> That's a syntax error. To avoid the syntax error, we need parentheses:
>     [(a, b, c) for (a, b, c) in iterable]
> and that's a no-op.

You are confusing here two distinct roles of the parenthesis:
disambiguation as in "(1 + 2) * 2", and tuple construction as in (1, 2, 3).
This overload is the reason that (1) is not a 1-tuple and we must write

You may argue that this overloading causes confusion and make this
construct hard to understand, but please be explicit about that; even if
<1, 2,3 > was the syntax for tuples, the expansion was still

 [(a, b, c) for (a, b, c) in iterable]

Since no tuple is constructed here.

Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to