Fun with fancy slicing

Fernando Perez fperez528 at yahoo.com
Fri Oct 3 17:53:34 EDT 2003


Alex Martelli wrote:

> How sweet it would be to be able to unpack by coding:
>     head, *tail = alist

+1000 :)

I'd LOVE to have this syntax around.  I'd even want:

head, *body, last = alist

and 

*head_and_body, last = alist

to both work in their respectively obvious ways ;) (left-to-right unpacking,
empty lists/tuples returned for elements which can't be unpacked --like if
alist contains just one element, and the lhs returning tuple/list based on the
type of the rhs).

We can dream :)

Cheers,

f




More information about the Python-list mailing list