Re: Partially unpacking a sequence

2006-04-07 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I have a list y > y > > ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', > '19.500', '224'] > > from which I want to extract only the 2nd and 4th item > > by partially > unpacking the list. So I tried > a,b = y[2,4] Mmm, so lovely and meaningful

Re: Partially unpacking a sequence

2006-04-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Thank you, everyone, for resolving my question. At one point, while > trying to solve the problem, I typed > > >>> y[1,3] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: list indices must be integers > > The error message gave me no clue as to

Re: Partially unpacking a sequence

2006-04-06 Thread jUrner
>> Thank you, everyone, for resolving my question. At one point, while >> trying to solve the problem, I typed >> > y[1,3] >> >> Traceback (most recent call last): >> File "", line 1, in ? >> TypeError: list indices must be integers >> >> The error message gave me no clue as to what I was doin

Re: Partially unpacking a sequence

2006-04-06 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: y[1,3] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: list indices must be integers > > The error message gave me no clue as to what I was doing wrong (in > my mind, I was just writing out the elements of a range), and I > tho

Re: Partially unpacking a sequence

2006-04-06 Thread Fredrik Lundh
Paul McGuire wrote: > Forgot one: > > _,_,a,_,b,_,_,_ = y > > There actually is some merit to this form. If the structure of y changes > sometime in the future (specifically if a field is added or removed), this > statement will fail noisily, calling your attention to this change. But if > a ne

Re: Partially unpacking a sequence

2006-04-06 Thread tkpmep
Thank you, everyone, for resolving my question. At one point, while trying to solve the problem, I typed >>> y[1,3] Traceback (most recent call last): File "", line 1, in ? TypeError: list indices must be integers The error message gave me no clue as to what I was doing wrong (in my mind, I was

Re: Partially unpacking a sequence

2006-04-06 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I have a list y > > >>>y > > ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', > > '19.500', '224'] > > > > from which I want to extract only t

Re: Partially unpacking a sequence

2006-04-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I have a list y > >>>y > ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', > '19.500', '224'] > > from which I want to extract only the 2nd and 4th item by partially > unpacking the list. So I tried > >>>a,b = y[2,4] > Traceback (most recent call last): >

Re: Partially unpacking a sequence

2006-04-06 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a list y > >>>y > ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', > '19.500', '224'] > > from which I want to extract only the 2nd and 4th item by partially > unpacking the list. So I tried > >>>a,b = y[2,4] > Trace

Partially unpacking a sequence

2006-04-06 Thread tkpmep
I have a list y >>>y ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', '19.500', '224'] from which I want to extract only the 2nd and 4th item by partially unpacking the list. So I tried >>>a,b = y[2,4] Traceback (most recent call last): File "", line 1, in ? TypeError: list indices