I want to convert multiple lists inside a list? I am doing it with a loop, but each sub list item doesn't get a comma between it.  myList = [['a','b','c','d'],['a','b','c','d']] myString = '' for x in myList:     myString += ",".join(x) print myString   ouput:  a,b,c,da,b,c,d   desired output:  a,b,c,d,a,b,c,d
Is there a simple way to flatten a list of iterables with a list comprehension, or failing that, what would you all consider to be the best way to flatten a shallow list like this, balancing performance and readability?  I tried to flatten such a list with a nested list comprehension, like this:  [image for image in menuitem for menuitem in list_of_menuitems]   But I get in trouble of the NameError variety there, because the name 'menuitem' is not defined.  After googling and looking around on Stack Overflow, I got the desired results with a reduce statement:  reduce(list.__add__, map(lambda x: list(x), list_of_menuitems))   But this method is fairly unreadable because I need that list(x) call there because x is a Django QuerySet object.  Conclusion:   Thanks to everyone who contributed to this question.  Here is a summary of what I learned.  I'm also making this a community wiki in case others want to add to or correct these observations.  My original reduce statement is redundant and is better written this way:  &gt;&gt;&gt; reduce(list.__add__, (list(mi) for mi in list_of_menuitems))   This is the correct syntax for a nested list comprehension (Brilliant summary !):  &gt;&gt;&gt; [image for mi in list_of_menuitems for image in mi]   But neither of these methods are as efficient as using itertools.chain:  &gt;&gt;&gt; from itertools import chain &gt;&gt;&gt; list(chain(*list_of_menuitems))   And as @cdleary notes, it's probably better style to avoid * operator magic by using chain.from_iterable like so:  &gt;&gt;&gt; chain = itertools.chain.from_iterable([[1,2],[3],[5,89],[],[6]]) &gt;&gt;&gt; print(list(chain)) &gt;&gt;&gt; [1, 2, 3, 5, 89, 6]
How old is SpongeBob? I don't mean how old is the series, I mean what is SpongeBob's age if he were a real person. I ask because his age seems to be ambiguous in the show.   He has a full-time job He has his own house He is always referred to as a kid (especially in the movie) He acts childish and immature In one episode, he was pretending to be an adult/grown-up $2+2 = 5$? error in proof $$\begin{align} 2+2 &amp;= 4 - \frac92 +\frac92\\ &amp;= \sqrt{\left(4-\frac92\right)^2} +\frac92\\ &amp;= \sqrt{16 -2\times4\times\frac92 +\left(\frac92\right)^2} + \frac92\\ &amp;= \sqrt{16 -36 + \left(\frac92\right)^2} +\frac92\\ &amp;= \sqrt {-20 +\left(\frac92\right)^2} + \frac92\\ &amp;= \sqrt{25-45 +\left(\frac92\right)^2} +\frac92\\ &amp;= \sqrt {5^2 -2\times5\times\frac92 + \left(\frac92\right) ^2} + \frac92\\ &amp;= \sqrt {\left(5-\frac92\right)^2} +\frac92\\ &amp;= 5 + \frac92 - \frac92 \\ &amp;= 5\end{align}$$  Where did I go wrong So I have an old unlocked phone and I'd like to load up my own OS.  I've seen some mods out there.  CyanogenMod seems to be the most popular.  However, I was curious if I could just install a pure untouched version of the OS -- as distributed by Google. I seem to remember being able to download a clean compiled version of the Android OS.    Does Google distribute any binaries like this, and if not, is there someone out there that does?    Additionally, is this even worth trying?  These days is it necessary for Android to be packaged with special drivers and such for all of the different hardware out there? I'm fairly new to blender and not a graphics person by any stretch of the imagination. I've been having some success though modelling semi-reflective glass for a project I wish to build (physically) and I'm wondering if it is possible to model the effects of a lens. The lens I wish to model is a double-convex type. It has a diameter of 120mm and a focal-length of 301mm. Is this something that can be modelled in blender and if so, how? I'd like to be able to position the camera close to this lens and reproduce the magnifying effects of the lens on the scene behind the lens as well as depth-of-field effects.  Thanks a lot. "a while" vs "awhile" Is there a difference between "awhile" and "a while"? If there is, what is it? I've been wondering this for awhile, but now I actually need the answer. Is there a way to exclude other particle systems from the effects of a Wind effect? I have a scene with a number of particle systems. I'd like to have a separate wind effect for my main scene and another for an extra: an emitter + wind-effect to blow leaves into my scene. I can't find any way to exclude, so here I am. At the very worst, I can just render the main scene and then render the wind effect and composite it, but I figured I'd check first. Implement numbering scheme like A,B,C... AA,AB,... AAA..., similar to converting a number to radix26 I want to implement numbering scheme like Microsoft Word uses for numbering.  first one gets = A,next is  B, next is C, .... then AA, then AB,....and so on.  as shown below   A        B  C  .   .  AA  AB  AC  .  .  AAA  AAB  ....   '=>' here means converted to.  some examples:       1 =&gt; A 26 =&gt; Z 27 =&gt; AA 52 =&gt; AZ 53 =&gt; BA   and heres the code for it:     var convertToNumberingScheme = function(n){         var x = n-1,             r26 = x.toString(26),             baseCharCode = "A".charCodeAt(0);          var arr = r26.split(''),             len = arr.length;          var newArr =arr.map(function(val,i){             val = parseInt(val,26);              if( (i === 0) &amp;&amp; ( len &gt; 1)){                 val = val-1;             }              return String.fromCharCode(baseCharCode + val);         });         return newArr.join('');     }   It seems to work fine, but any ideas if there are some potential bugs or ways to  optimize this. How do I clone a generic list in C#? I'm from the State of Kuwait and hold an Eritrean passport. I'm planning to visit UK in October but my visa will expire in November.    Is it OK to make a journey in the last month of my visa, provided that I make sure that I book my plane back before expiring date? Inequality Regarding e As many people already know, there are several ways to trigger Windows 7 Aero Snap feature. A user can either press Win+{Left,Right,Up,Down} to snap the window to the left or right or maximize or restore. One can also drag the title bar to all the corner except bottom one.  However, is there any keyboard or mouse shortcut to place one window on top half the screen, and another window on bottom half the screen? Please do not tell me to use "Show Windows Stacked" because if I have more than two windows, it will place ALL the windows horizontally, which is not what I want. I want to be able to select the window I want and place it automatically either on top or bottom half the screen.  Thanks!  Edit: Thanks for Moab's suggestion, both on recommend WinSplit and updating my question.  I should make it more clear that I'm looking for a software that will do the functions WinSplit provided, but with on screen input, such as touch screen or pen. Limit of $\lim_{n\rightarrow \infty} \sum^{n}_{i=1} \frac{1}{\sqrt {n^2 +i} }$ Why is the Yang–Mills existence and mass gap problem so fundamental? Ref:   Can anyone please explain why the Yang–Mills Existence and Mass Gap problem is so important / fundamental to contemporary mathematics (and, presumably, theoretical / mathematical physics)?  If possible, please include the following in your answer / response:  (1) Why the problem is so fundamental / important - for both mathematics and theoretical / mathematical physics; (2) How the solution to the problem would impact research in the above two fields; (3) (If applicable) What progress has been made so far in resolving it; (references to papers, books, other resources would be helpful).  I'm an upper-level undergraduate in theoretical physics, and so am seeking an answer / response at such level. Cron fails with exit status 127 How do moving charges produce magnetic fields? What's the difference between adjusting highlights and shadows in the basic panel and in the tone curve in the Develop Module of Lightroom? I wanted to reduce some highlights in a photo and found that there were two possible ways of doing so: one from the basic panel and another from the tone curve. when I reduce the highlights in one pane the value on the other is unchanged. Are both of them the same thing? Which would be better? Why is integration the inverse of differentiation Is it possible to flash a smartphone like the Samsung Galaxy SIII or an LG Optimus 4X with a vanilla Android ROM like the one that has been flashed on Galaxy Nexus or Motorola phones (I think)?  I am asking because manufacturers like Samsung, LG, HTC tend to make ROMs for their smartphones and tablets with preinstalled launchers like Touchwiz or HTC Sense. They explain their decision by saying that they want to make their devices to look unique against their rival devices. The problem is that Android updates for their phones and tablets get delayed and there are incidents in which some devices - which are more than capable of running the upcoming version of Android - fall way behind or never get updated at all.   So, what I am basically asking here is if there is a way to install vanilla Android, excluding CyanogenMod or any other modified vanilla ROMs, on an Android based smartphone? IVP Differential Equation I have stumbled across a very old exam question from my linear algebra course and the solutions are not available. I was wondering if my working/logic is correct and if any improvements can be made.     Let  $\ B=\begin{pmatrix}     1 &amp; -1 &amp; 4 \\     6 &amp; -7 &amp; 2 \\     -3 &amp; 1 &amp; -6       \end{pmatrix}\ $ and $\ \vec{v_1}=\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}$.      Part (i): Calculate $(B+5I)\vec{v_1}$ and $(B+5I)^2\vec{v_1}$.   Using simply matrix multiplication, I calculated $(B+5I)\vec{v_1}=\begin{pmatrix} 1 \\ 2 \\ -1 \end{pmatrix}$ and $(B+5I)^2\vec{v_1}=\vec{0}$.     Part (ii): Find all eigenvalues and eigenvectors of B.   From our calculations in part (i), we can see that $\ \lambda=-5,-5$ are two of the eigenvalues, with corresponding eigenvector $\ \begin{pmatrix} 1 \\ 2 \\ -1 \end{pmatrix}$ and generalised eigenvector $\ \begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}$. From the trace of B, the remaining eigenvalue is $\lambda=-2$ with corresponding eigenvector $\begin{pmatrix} -2 \\ -2 \\ 1 \end{pmatrix}$.     Part (iii): Giving reasons, write down a basis for the generalised eigenspace $GE_{-5}$ of B.   I am unsure of this part of the question. If I had to guess, I would say a basis for $GE_{-5}=\left\{\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix},\begin{pmatrix} 1 \\ 2 \\ -1 \end{pmatrix}\right\}$. Is this correct?     Part (iv): Solve the initial value problem $\vec{y'}=B\vec{y}$ where $\ B=\begin{pmatrix}     1 &amp; -1 &amp; 4 \\     6 &amp; -7 &amp; 2 \\     -3 &amp; 1 &amp; -6       \end{pmatrix}\ $ and $\vec{y}(0)=\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}$.   Well, the solution to this IVP will take the form $\vec{y}=e^{tB}\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}$. I noticed that $\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}$ was a generalised eigenvector and hence we can write $\vec{y}=e^{-5t}\begin{pmatrix} 1 \\ 1 \\ -1 \end{pmatrix}+e^{-5t}\begin{pmatrix} 1 \\ 2 \\ -1 \end{pmatrix}t$. Thus $\vec{y}=e^{-5t}\begin{pmatrix} 1+t \\ 1+2t \\ -1-t \end{pmatrix}$ #!/bin/bash  SUBJECT="WARNING CPU USAGE HIGH" TO=gmail id MESSAGE=/tmp/messages echo "#######################" &gt; $MESSAGE echo "CPU statistics as follows.." &gt;&gt; $MESSAGE mpstat &gt;&gt; $MESSAGE echo "#######################" &gt;&gt; $MESSAGE CPU_USAGE=$(top -b -n1 | awk '/^Cpu/ {print $2}' | cut -d. -f1) [ $CPU_USAGE -gt 85 ] &amp;&amp; mail -s "$SUBJECT" "$TO" &lt; $MESSAGE`   ./cpu.sh: line 11: [: -gt: unary operator expected What might be the reason