Re: assign only first few items of a tuple/list

2012-12-04 Thread Tim Chase
On 12/04/12 15:36, Chris Angelico wrote: > On Wed, Dec 5, 2012 at 8:25 AM, Daniel Fetchinson > wrote: >> Hi folks, I swear I used to know this but can't find it anywhere. >> Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. >> I'd like to assign the first two items to tw

Re: assign only first few items of a tuple/list

2012-12-04 Thread Dave Angel
On 12/04/2012 04:36 PM, Chris Angelico wrote: > On Wed, Dec 5, 2012 at 8:25 AM, Daniel Fetchinson > wrote: >> Hi folks, I swear I used to know this but can't find it anywhere. >> Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. >> I'd like to assign the first two items

Re: assign only first few items of a tuple/list

2012-12-04 Thread Terry Reedy
On 12/4/2012 4:36 PM, Chris Angelico wrote: On Wed, Dec 5, 2012 at 8:25 AM, Daniel Fetchinson wrote: Hi folks, I swear I used to know this but can't find it anywhere. Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. I'd like to assign the first two items to two varia

Re: assign only first few items of a tuple/list

2012-12-04 Thread Chris Angelico
On Wed, Dec 5, 2012 at 8:25 AM, Daniel Fetchinson wrote: > Hi folks, I swear I used to know this but can't find it anywhere. > Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. > I'd like to assign the first two items to two variables, something like, > > a, b, _ = x > >

assign only first few items of a tuple/list

2012-12-04 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere. Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. I'd like to assign the first two items to two variables, something like, a, b, _ = x but the above will not work, of course, but what is the common idiom