unary star

Terry Reedy tjreedy at udel.edu
Tue May 6 15:34:38 EDT 2003


"VanL" <vlindberg at verio.net> wrote in message
news:uwPta.2214$Nf.2180 at sea-read.news.verio.net...
> I like this idea -- I frequently find myself in situations where I
want
> to take only the first item from a list.  (I usually reverse the
list,
> and then pop() it.)

>>> l=[0,1,2]
>>> l.pop(0)
0
>>> l
[1, 2]

Yes, this does shift l[1:], but that is faster than making a copy as
you propose.

>I would vastly prefer a
>first, *rest = some_list

Terry J. Reedy






More information about the Python-list mailing list