Pythonification of the asterisk-based collection packing/unpacking syntax

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Dec 29 08:23:24 EST 2011


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.


-- 
Steven



More information about the Python-list mailing list