how best to split into singleton and sequence

Erik Max Francis max at alcyone.com
Tue Oct 18 21:40:05 EDT 2005


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.

Did you want to only split once at most?  Then it's s.split('|', 1). 
Did you want to assign the first element to the first variable and the 
rest to the next?  Then it's x = s.split('|'); a, b = x[0], x[1:].

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   It's funny when you think about it / How coincidence rules
   -- Anggun



More information about the Python-list mailing list