variable length tuple assignment

Helmut Jarausch jarausch at igpm.rwth-aachen.de
Wed Feb 25 04:16:38 EST 2009


Sorry if this is too simple but I couldn't find.

I vaguely remember there is a means to assign a variable length tuple
and catch the 'rest'  like

S="a,b,c,d"

(A,B,<list of remaining items>) = S.split(',')

I know I could do
SL= split(',')
(A,B)=SL[:2]
Rest= SL[2:]

but is there some shorthand for this?

Many thanks for a hint,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany



More information about the Python-list mailing list