[Python-ideas] iterable.__unpack__ method

Nick Coghlan ncoghlan at gmail.com
Tue Feb 26 04:50:18 CET 2013


On Tue, Feb 26, 2013 at 11:20 AM, João Bernardo <jbvsmo at gmail.com> wrote:
>
> 2013/2/25 Greg Ewing <greg.ewing at canterbury.ac.nz>
>>
>> João Bernardo wrote:
>>>
>>> Python already supports this odd syntax
>>>
>>>     a, b, *[] = iterable
>>>
>>> because it interprets the [] not as an empty list, but as an empty "list
>>> of identifiers". Maybe it could be used for something useful.
>>
>>
>> No, because it already has a meaning: there must be no more
>> values left in the sequence.
>>
>
> Why have two things with the same meaning?
>
>     a, b = iterable
>
>     a, b, *[] = iterable
>
> Both are the same... The *[] thing is about 100% useless right now.

And almost certainly an unintentional quirk of the way the Grammar is
constructed.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list