Pythonification of the asterisk-based collection packing/unpacking syntax

Eelco hoogendoorn.eelco at gmail.com
Wed Dec 28 07:05:00 EST 2011


On Dec 28, 2:11 am, Rick Johnson <rantingrickjohn... at gmail.com> wrote:
> On Dec 27, 5:10 pm, Steven D'Aprano <steve
>
> +comp.lang.pyt... at pearwood.info> wrote:
> > On Sun, 25 Dec 2011 07:47:20 -0800, Eelco wrote:
> > Your original use-case, where you want to change the type of tail from a
> > list to something else, is simply solved by one extra line of code:
>
> > head, *tail = sequence
> > tail = tuple(tail)
>
> i wonder if we could make this proposal a bit more "Pythonic"? Hmm...
>
> head, tuple(tail) = sequence
>
> ...YEP!

That has been considered; it was my first thought too, but this
requires one to break the symmetry between collection packing and
unpacking.



More information about the Python-list mailing list