Re: Converting a list of lists to a single list

2013-07-24 Thread steve
Wow, thanks everyone. Very helpful indeed! On Tuesday, July 23, 2013 2:52:21 PM UTC-7, st...@divillo.com wrote: > I think that itertools may be able to do what I want but I have not been able > to figure out how. > > > > I want to convert an arbitrary number of lists with an arbitrary number o

Re: Converting a list of lists to a single list

2013-07-24 Thread Terry Reedy
On 7/23/2013 7:02 PM, Terry Reedy wrote: On 7/23/2013 5:52 PM, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. What you want is a flattened product with unchanged components of the successive products omitted in the fla

Re: Converting a list of lists to a single list

2013-07-23 Thread Chris Angelico
On Wed, Jul 24, 2013 at 8:34 AM, Rafael Durán Castañeda wrote: > In [3]: [ y for y in itertools.chain.from_iterable(x)] > Out[3]: ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] Complete aside, given that this has already been pointed out as solving a different problem: Any time you see a

Re: Converting a list of lists to a single list

2013-07-23 Thread Terry Reedy
On 7/23/2013 5:52 PM, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. A recursive generator suffices. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list a

Re: Converting a list of lists to a single list

2013-07-23 Thread Zero Piraeus
: On 23 July 2013 17:52, wrote: > > Say I have three lists: > > [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] > > I would like to convert those to a single list that looks like this: > [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] H

Re: Converting a list of lists to a single list

2013-07-23 Thread MRAB
On 23/07/2013 22:52, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists

Re: Converting a list of lists to a single list

2013-07-23 Thread Rafael Durán Castañeda
El 23/07/13 23:52, st...@divillo.com escribió: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] Hi, I think you are looking for itertools.chain, or in this case, itertools.chain.from_iterable: In [1]: x = [['A0','A1','A2'], ['B0','B1','B2'], ['C0','C1','C2']] In [2]: import itertools In [3]: [ y for y

Converting a list of lists to a single list

2013-07-23 Thread steve
I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would