[Python-ideas] PEP for issue2292, "Missing *-unpacking generalizations"

Joshua Landau joshua.landau.ws at gmail.com
Mon Jul 15 13:19:21 CEST 2013


On 15 July 2013 12:17, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
> On 15 July 2013 12:08, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
>> On 15 July 2013 11:40, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
>>>
>>> Also this may be outside the scope of this PEP but since unpacking is
>>> likely to be overhauled I'd like to put forward a previous suggestion
>>> by Greg Ewing that there be a way to unpack some items from an
>>> iterator without consuming the whole thing e.g.:
>>>
>>>     a, ... = iterable
>>
>> That's definitely outside of this PEP's scope ;). Also, I think you
>> oversimplified your last version -- you still need a try-except
>> AFAICT.
>
> Where? The point is that next() raises StopIteration which is not an
> acceptable type of Error. Leaking the StopIteration makes the function
> not "generator-safe" i.e. if you call it from a generator the
> StopIteration could terminate an outer loop. That's why I have the
> try/except.
>
> As long as
>
>    a, ... = iterator
>
> gives me a ValueError I'm happy to let the error propagate upwards.

I misread the original, apologies.


More information about the Python-ideas mailing list