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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 30 23:44:00 EST 2017

Steve Barnes wrote:
> Since the practical 
> difference between remainder being the (partly exhausted) iterator and 
> it being a list, (itself an iterator),

A list is *not* an iterator, it's a sequence. There's
a huge difference. Items of a sequence can be accessed
at random, it can be iterated over multiple times,
if it's mutable its contents can be changed, etc.
None of that can be done to an iterator.

Maybe it would have been a defensible design decision
when *-unpacking was introduced, but it's too late to
change it now.

Even if it weren't, there are arguments against it.
It would be inconsistent with the usage of * in an
argument list, where the function always receives a
new tuple, never an iterator over something passed as
a * argument.


More information about the Python-ideas mailing list