Re: how best to split into singleton and sequence

2005-10-18 Thread [EMAIL PROTECTED]
what you wrote is the most readable to me: just asign the first 2 element to t, l respectively and forget about the rest. I assume that is what you want. I think perl may do it this way. A solution which I think looks uglier is : t, l = s.split('|')[:2] Randy Bush wrote: > >>> l = [] > >>> s =

Re: how best to split into singleton and sequence

2005-10-18 Thread Erik Max Francis
Randy Bush wrote: > so, i imagine what is happening is the lhs, t,l, is really > (t, (l)), i.e. only two items. > > so how should i have done this readably and simply? Your question isn't at all clear. You're trying to assign a 4-element tuple to two elements. That generates a ValueError. Di

Re: how best to split into singleton and sequence

2005-10-18 Thread George Sakkis
"Randy Bush" <[EMAIL PROTECTED]> wrote: > >>> l = [] > >>> s = 'a|b' > >>> t, l = s.split('|') > >>> t > 'a' > >>> l > 'b' > >>> s = 'a|b|c|d' > >>> t, l = s.split('|') > Traceback (most recent call last): > File "", line 1, in ? > ValueError: too many values to unpack > >>> > > so, i imagine wh

how best to split into singleton and sequence

2005-10-18 Thread Randy Bush
>>> l = [] >>> s = 'a|b' >>> t, l = s.split('|') >>> t 'a' >>> l 'b' >>> s = 'a|b|c|d' >>> t, l = s.split('|') Traceback (most recent call last): File "", line 1, in ? ValueError: too many values to unpack >>> so, i imagine what is happening is the lhs, t,l, is really (t, (l)), i.e. only two it