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

Mike Miller python-ideas at mgmiller.net
Mon Nov 27 21:31:28 EST 2017


Hmm, I didn't like the options below because they say to me, "consume everything:"

     x, y, * = iterable
     x, y, ... = iterable


Believe the question behind the idea was, how to grab a couple items and then 
*stop?*  If the syntax route is chosen, I'd expect something that tells me it is 
going to stop, like a "full stop" as the period/dot is called in jolly ol' 
England, e.g.:

     x, y, . = iterable

Not sure about the second comma though.

-Mike



On 2017-11-27 13:18, Greg Ewing wrote:
> Chris Angelico wrote:
>> The problem is that it depends on internal whitespace to
>> distinguish it from augmented assignment;
> 
> Ah, didn't spot that. I guess the ellipsis is the next best
> thing then.
> 
> An alternative would be to require parens:
> 
>     (x, y, *) = z


More information about the Python-ideas mailing list