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

Steven D'Aprano steve at pearwood.info
Mon Nov 27 19:31:56 EST 2017

On Tue, Nov 28, 2017 at 11:15:56AM +1300, Greg Ewing wrote:
> Guido van Rossum wrote:
> >While it appears to rhyme with the use of a lone 
> >'*' in function signatures, it would actually mean the opposite: in 
> >signatures it means "don't allow any more".
> That's the usage that's out of step with the rest -- all
> the others can be seen as some form of wildcard.
> So it's already confusing, and I don't think adding another
> wildcard meaning would make things any worse.

How does "stop iterating here" equate to a wildcard?

We already have a "wildcard" for iterable unpacking, using the extended 
iterable unpacking syntax:

    x, y, *z = iterable

which unpacks the first two items into x and y and the rest into z. This 
is the opposite: *stop* unpacking, so that after x and y are unpacked 
the process stops. I don't see how this is conceptually a wild card.


More information about the Python-ideas mailing list