Pythonification of the asterisk-based collection packing/unpacking syntax

Eelco hoogendoorn.eelco at gmail.com
Tue Dec 27 05:01:34 EST 2011


On Dec 27, 1:52 am, Chris Angelico <ros... at gmail.com> wrote:
> On Tue, Dec 27, 2011 at 10:44 AM, Eelco <hoogendoorn.ee... at gmail.com> wrote:
> > extended collection unpacking, as in 'head,*tail=sequence', is quite a
> > rare construct indeed, and here I very strongly feel a more explicit
> > syntax is preferrable.
>
> You may be right, but...
>
> > ... if collection packing/unpacking would be
> > presented as a more general construct from the start,
> > 'head,tail::tuple=sequence' would be hard to miss.
>
> ... it doesn't really justify a _change_. When a language is in its
> infancy and the only code written in it is on the designers' own
> computers, these sorts of debates can be tipped by relatively small
> differences - is it more readable, is it quick enough to type, etc.
> But once a language reaches a level of maturity, changes need to
> overwhelm the "but it's a change" hurdle - breaking existing code is
> majorly dangerous, and keeping two distinct ways of doing something
> means you get the worst of both worlds.
>
> We can argue till the cows come home as to which way would be better,
> _had Python started with it_. I don't think there's anything like
> enough difference to justify the breakage/duplication.

That I agree with; I think it is a questionable idea to introduce this
in a new python 3 version. But I consider it a reasonable change for a
'python 4', or whatever the next major version change will be called.
Writing a code-conversion tool to convert from *args to args::tuple
would be quite easy indeed.



More information about the Python-list mailing list