multiple assignment

Magnus Lycka lycka at carmen.se
Fri Mar 24 13:26:06 CET 2006


Anand wrote:
> Suppose i have a big list and i want to take tke the first one and rest
> of the list like car/cdr in lisp.
> is there any easy way to do this in python?

It seems like overkill to me to make the syntax more
complex just to avoid writing a one-line function.

def first_rest(seq): return seq[0], seq[1:]



More information about the Python-list mailing list