[Python-ideas] Generator unpacking

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Feb 13 16:40:26 EST 2016


Nick Coghlan wrote:
> On 13 February 2016 at 17:59, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 
>>  a, b, * = some_iter
> 
> The main problem with that specific spelling of the idea is that it's
> the inverse of what the bare "*" means when declaring function
> parameters

I know, but despite that, this still seems like tbe
"obvious" way to spell it to me.

>     a *= value
> 
> and
> 
>     a, b, *= value
> 
> mean wildly different things.

Another possibility is

    a, b, ... = value

> 2. When you do really need it, islice handles it

I find that answer unsatisfying, because by using islice
I'm telling it to do *more* work, whereas I really want to
tell it to do *less* work. It just seems wrong, like a
kind of abstraction inversion.

-- 
Greg


More information about the Python-ideas mailing list