[Python-3000] PEP 3132: Extended Iterable Unpacking

Georg Brandl g.brandl at gmx.net
Thu May 3 13:46:10 CEST 2007


Simon Percivall schrieb:
> On 2 maj 2007, at 20.08, Guido van Rossum wrote:
>> [Georg]
>>>>>>>> a, *b, c = range(5)
>>>>>>>> a
>>>>>     0
>>>>>>>> c
>>>>>     4
>>>>>>>> b
>>>>>     [1, 2, 3]
>>
>> <snip>
>> That sounds messy; only allowing *a at the end seems a bit more
>> manageable. But I'll hold off until I can shoot holes in your
>> implementation. ;-)
> 
> As the patch works right now, any iterator will be exhausted,
> but if the proposal is constrained to only allowing the *name at
> the end, wouldn't a more useful behavior be to not exhaust the
> iterator, making it similar to:
> 
>  > it = iter(range(10))
>  > a = next(it)
>  > b = it
> 
> or would this be too surprising?

IMO yes.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list