"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 "<stdin>", 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 items.
>
> so how should i have done this readably and simply?

>>> s = 'a|b|c|d'
>>> l = s.split('|')
>>> t = l.pop(0)

By the way, don't use 'l' as an identifier; it is very close to '1' visually.

George


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to