[Python-ideas] How assignment should work with generators?

Paul Moore p.f.moore at gmail.com
Mon Nov 27 17:27:20 EST 2017


On 27 November 2017 at 21:54, Kirill Balunov <kirillbalunov at gmail.com> wrote:
> 2017-11-27 19:23 GMT+03:00 Paul Moore <p.f.moore at gmail.com>:
>
>>
>> It should be reasonably easy
>> to do a code search for something like "=.*islice", to find code
>> that's a candidate for using the proposed syntax. I suspect there's
>> very little code like that.
>
>
> While isclice is something  equivalent, it can be used in places like:
>
> x, y = seq[:2]
> x, y, z = seq[:3]

But in those places,

x, y, *_ = seq

works fine at the moment. So if the programmer didn't feel inclined to
use x, y, *_ = seq, there's no reason to assume that they would get
any benefit from x, y, ... = seq either.

Paul


More information about the Python-ideas mailing list