Pythonification of the asterisk-based collection packing/unpacking syntax

Lie Ryan lie.1296 at gmail.com
Thu Dec 29 18:24:57 EST 2011


On 12/30/2011 12:23 AM, Steven D'Aprano wrote:
> On Thu, 29 Dec 2011 03:55:14 -0800, Eelco wrote:
>
>> I would argue that the use of single special characters to signal a
>> relatively complex and uncommon construct is exactly what I am trying to
>> avoid with this proposal.
>
> This would be the proposal to change the existing
>
>      head, *tail = sequence
>
> to your proposed:
>
>      head, tail:: = ::sequence
>
> (when happy with the default list for tail), or
>
>      head, tail::tuple = ::sequence
>
> to avoid an explicit call to "tail = tuple(tail)" after the unpacking.
>
> Either way, with or without an explicit type declaration on the left hand
> side, you are increasing the number of punctuation characters from one to
> four. If your aim is to minimize the number of punctuation characters,
> you're doing it wrong.

Another drawback of it is that it looks misleadingly similar to C++ 
namespace notation.




More information about the Python-list mailing list