[Python-ideas] Fwd: unpacking generalisations for list comprehension

Sven R. Kunze srkunze at mail.de
Thu Oct 13 04:37:35 EDT 2016


On 13.10.2016 01:29, Steven D'Aprano wrote:
> On Wed, Oct 12, 2016 at 06:32:12PM +0200, Sven R. Kunze wrote:
>>
>> So, my reasoning would tell me: where have I seen * so far? *args and
>> **kwargs!
> And multiplication.

Multiplication with only a single argument? Come on.


> And sequence unpacking.

We are on the right side of the = if any and not no the left side.

>
>> [...] is just the list constructor.
> Also indexing: dict[key] or sequence[item or slice].

There's no name in front of [. So, I cannot be an index either.


Nothing else matches (in my head) and I also don't see any ambiguities. 
YMMV.

I remember a new co-worker, I taught how to use *args and **kwargs. It 
was unintuitive to him on the first time as well.

About the list constructor: we construct a list by writing [a,b,c] or by 
writing [b for b in bs]. The end result is a list and that matters from 
the end developer's point of view, no matter how fancy words you choose 
for it.

Cheers,
Sven


More information about the Python-ideas mailing list