destructuring tuple and list

Diez B. Roggisch deetsNOSPAM at web.de
Thu Mar 18 05:10:15 EST 2004


Hans Nowak wrote:

> Diez B. Roggisch wrote:
> 
>> I've also thought about that. s/t like real pattern matching might be
>> cool, but is probably too much of a paradigm shift.
>> 
>> What I do is this:
>> 
>> l = (5,6,3,4)
>> x,y,tail = l[0:2], l[:2]
> 
> This does not seem to work, though:
> s, 
> 

Yep, that was a typo. Of course the second slice has to look like this:

l[2:]

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list