I have mat = [[0]*5]*5 to create a 2-d matrix of all zeros.  When I do mat[0][0] = 1, I want it to be only  [[0, 1, 0, 0, 0],  [0, 0, 0, 0, 0],  [0, 0, 0, 0, 0],  [0, 0, 0, 0, 0],   [0, 0, 0, 0, 0]]   but when I print mat, I get:   [[0, 1, 0, 0, 0],  [0, 1, 0, 0, 0],  [0, 1, 0, 0, 0],  [0, 1, 0, 0, 0],   [0, 1, 0, 0, 0]]   How do I access an individual element?
I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it?
What is the difference between the "...", '...', $'...', and $"..." quotes in the shell? Sometimes I see shell scripts use all of these different ways of quoting some text: &quot;...&quot;, '...', $'...', and $&quot;...&quot;. Why are there so many different kinds of quote being used? Do they behave differently or affect what I can do inside them? Photoshop To CSS: How do you translate Fill to CSS Lightning: why can you not have an expression combined with text in an HTML attribute? So, I've been struggling with this for a while, trying to figure out how to get it to work. Here is what I originally did:  &lt;button class="btn btn-primary {!v.isLink1 ? 'active' : ''}"&gt;   And so on. Here's the documentation on it.   However, when you actually try to save this in the developer console, you get the error:  Field Integrity Exception: Failed to save undefined: Cannot mix expression and literal string in attribute value, try rewriting like {!'foo' + v.bar}: Source   I finally figured out that you have to put all of the classes inside of the expression, like so:  &lt;button class="{!v.isLink1 ? 'btn btn-primary active' : 'btn btn-primary'}"&gt;   This doesn't seem very intuitive. It's also not documented anywhere I could find. Could someone explain to me why it is this way and if it will ever change?   (and hopefully this question saves someone some headaches in the future) Global and local variables in R shebang line not working with cr-lf How to tail multiple files using tail -0f in Linux/AIX I tried tailing two files using the option:  tail -0f file1.log -0f file2.log   In Linux I see an error "tail : can process only one file at a time".  In AIX I see the error as "Invalid options".  This works fine when I use:  tail -f file1 -f file 2   in Linux but not in AIX.  I want to be able to tail multiple files using -0f or -f in AIX/Linux  multitail is not recognized in either of these OS. Recently I began studying machine learning, however I failed to grasp the intuition behind .   The following are the facts about logistic regression that I understand.   As the basis for hypothesis we use . I do understand why it's a correct choice, however why it's the only choice I don't understand. Hypothesis represents the probability that the appropriate output is $1$, therefore the domain of our function should be $[0,1]$, this is the only property of sigmoid function I found useful and appropriate here, however many functions satisfy this property. In addition, sigmoid function has a derivative in this form $f(x)(1-f(x))$, but I don't see the utility of this special form in logistic regression.   Question: what so special about sigmoid function, and why we cannot use any other function with domain $[0,1]$? The cost function consists of two parameters ${\rm Cost}(h_{\theta}(x),y)=-\log(h_{\theta}(x))$ if $y=1, {\rm Cost}(h_{\theta}(x),y)=-\log(1-h_{\theta}(x))$ if $y=0$. In the same was as above, I do understand why it's correct, however why is it the only form? For example, why couldn't $|h_{\theta(x)}-y|$ be a good choice for the cost function?  Question: what is so special about the above form of cost function; why cannot we use another form?   I would appreciate if you could share your understanding of logistic regression. Cross-reference packages: which to use, which conflict? How does a non-mathematician go about publishing a proof in a way that ensures it to be up to the mathematical community's standards? I'm a computer science student who is a maths hobbyist. I'm convinced that I've proven a major conjecture. The problem lies in that I've never published anything before and am not a mathematician by profession. Knowing full well that my proof may be fallacious, erroneous, or simply lacking mathematical formality, what advice would you give me? How do I execute PHP that is stored in a MySQL database? I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load.  How could I go about doing this? Can we please hold the hats? I really like the hats game. But I would love to keep the hats longer then only one winter. I want to leave them in my wardrobe during summer. Last year, I collected some cool hats, and I apparently lost them during summer.  Maybe we could make a system that allows hats to last for about 2 or 3 years, so we don't have to start over each winter. Or even specify per type of hat a number of years they last? Very very rare hats could last for ever.  I asked this, simply because I love hats! :D Preserve blend mode effect when underneath layers are disabled? (Photoshop) How can I set the processor affinity of a process on Linux? How can I set the processor affinity of a process on Linux? Column and row padding in tables How do you guys go about controlling column padding in tables?   Update  To clarify, I'm looking for a way to control both vertical and horizontal padding. So, if I had a simple table like in the following code snippet, I could pad the columns and make them look a bit less... ugly. :P   \begin{tabular}{|l|l|}     \hline     column 1 &amp; column 2 \\      \hline     I really would like this less &amp; crammed\\     \hline \end{tabular}   I tried this by using the command \vspace but it leaves gaps in the vertical lines. Java split() method strips empty strings at the end? How to inset a face? I am trying to set up a Minecraft rig mouth that will have more controls and will be rounded, but I am having issues trying to figure out what this guy did here. First, he did what looked like a loop cut and slide, but instead of drawing a line it selected all the edges it passed through. He then cut to a new clip where the mouth was already set up like this.    The video is in 3 times speed but if you download a youtube plugin you can slow it down to 0.25 speed of the video and then if you do the spacebar trick you can slow it down so it shows 1 frame at a time and it is really slow.  if you want or need to see the video.  All I am asking is how can I create those 8 basic segments. Is it acceptable to add a duplicate answer to several questions? How can I install Ubuntu on a headless machine? I have a headless storage server with preconfigured Windows Home Server. How can I install Ubuntu without a display?  Do I have to build a custom install flash drive? If so, what would be the basic procedure? Is there a program (like unetbootin) to do this? What is the difference between OpenOffice and the newly created LibreOffice? What is the difference between OpenOffice and LibreOffice? I understand that LibreOffice is another fork that is going to be developed. I have used OpenOffice since v1 and am wondering if there is a definite advantage to uninstalling and trying LibreOffice. What to do when OP answers his/her own question in an edit? Reference question:   Sometimes users solve their own questions, which is great. Sometimes they say they've solved it and move on, which is not so great. The above question is middle-ground: the user posted an answer to his own question, but as an edit to the question instead of as a real answer.  Should any action be taken in such a case? The obvious solution is to copy the edit into a real answer. But is this the right solution? In this case, the answer is a little hidden and there are no other answers, so it appears on the unanswered list.     Related: