On 23 October 2012 21:06, Joshua Landau <span dir="ltr"><<a href="mailto:joshua.landau.ws@gmail.com" target="_blank">joshua.landau.ws@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On 23 October 2012 21:03, Joshua Landau <span dir="ltr"><<a href="mailto:joshua.landau.ws@gmail.com" target="_blank">joshua.landau.ws@gmail.com</a>></span> wrote:<br><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 23 October 2012 12:07, Jean-Michel Pichavant <span dir="ltr"><<a href="mailto:jeanmichel@sequans.com" target="_blank">jeanmichel@sequans.com</a>></span> wrote:<br></div><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>----- Original Message -----<br>
<br>
> Thankyou.. but my problem is different than simply joining 2 lists<br>
> and it is done now :)....<br>
<br>
<br>
</div>A lot of people though you were asking for joining lists, you description was misleading.<br>
<br>
I'll take a guess: you want to flatten a list of list.<br>
"Nested" list comprehensions can do the trick.<br>
<br>
aList =[[1,5], [2,'a']]<br>
[item for sublist in aList for item in sublist]<br>
<br>
...<br>
[1, 5, 2, 'a']<br>
<br>
I find it rather difficult to read though.</blockquote><div><br></div></div><div>We have a library function for this, in the one-and-only itertools.</div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



>>> listoflists = [list(range(x, 2*x)) for x in range(5)]<br>>>> listoflists<br>[[], [1], [2, 3], [3, 4, 5], [4, 5, 6, 7]]<br>>>> from itertools import chain<br> >>> list(chain.from_iterable(listoflists))<br>



[1, 2, 3, 3, 4, 5, 4, 5, 6, 7]</blockquote></div><div><br></div></div>It does exactly what it says... fast and easy-to-read.
</blockquote></div><br></div></div><div>Note that I think what he really wanted is to go from</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


a, b, c = [list(x) for x in (range(10), range(11, 20), range(21, 30))]</blockquote><div>to</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


list(range(30))</blockquote>
</blockquote></div><br><div>UNDO! UNDO! UNDO!</div><div><br></div><div>I <i>meant </i>to say:</div><div><br></div><div><div>Note that I think what he really wanted is to go from</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

a, b, c = [list(x) for x in (range(10), range(11, 20), range(21, 30))]</blockquote><div>to</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

[a, b, c]</blockquote></div>