[Python-ideas] Generator unpacking

Chris Angelico rosuav at gmail.com
Mon Feb 15 03:54:14 EST 2016


On Mon, Feb 15, 2016 at 7:39 PM, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> On Feb 15, 2016, at 00:12, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>> IMO, the other downside is that the semantic difference between
>>
>>    a, b, ... = value
>>
>> and
>>
>>    a, b, *_ = value
>>
>> is very subtle, and (even worse) only significant if value is an
>> iterable as opposed to a concrete container such as a list.
>
> You mean iterator, not iterable. And being "concrete" has nothing to do with it--a dict view, a memoryview, a NumPy slice, etc. aren't iterators any more than a list is.
>

Allow me to take this opportunity to reiterate the recommendation for
"reiterable", which has come up enough times that I've completely
forgotten who first came up with it. An iterable can be iterated over
at least once; a reiterable can be iterated over more than once, and
will often produce the same sequence of values each time.

ChrisA


More information about the Python-ideas mailing list