Different methods for constructing the same empty nested list in python results in inconsistent behaviour I'm using Python 2.7.12.  I'm having a problem that I think is best explained through example.  Why does the .append() behaviour of c differ from a and b?  #Three different but equivalent methods to construct empty list:  a = [] for i in range(10):     a.append([])  b = [[] for _ in range(10)]  c = [[]]*10  print a print b print c  #Check to make sure they're equivalent. They are. print a==b print b==c print a==c  #Carry out the same operation on all lists a[1].append(6) b[1].append(6) c[1].append(6)  #Woah!  c is now different than a and b! print a print b print c  print a==b print b==c print a==c   OUTPUT:  [[], [], [], [], [], [], [], [], [], []] [[], [], [], [], [], [], [], [], [], []] [[], [], [], [], [], [], [], [], [], []] True True True [[], [6], [], [], [], [], [], [], [], []] [[], [6], [], [], [], [], [], [], [], []] [[6], [6], [6], [6], [6], [6], [6], [6], [6], [6]] True False False
List of lists changes reflected across sublists unexpectedly 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?
Where should the period be put when an entire sentence is quoted at the end of a sentence? Find the coefficient of the term $x^2$ in $\left(x+\frac 2x\right)^{4}$ Find the coefficient of the term $x^2$ in $$\left(x+\frac 2x\right)^{4}$$   This is what I have done so far.  We know $a$ = $x$ and $b$ = $\frac2x$ and $n$ = 4  So what I have done is $4c2$ x $(x)^2$ x ($\frac2x$)$^2$  As we know that $^2$ + $^2$ = 4, and 4 is the $n$ value.  The answer is one though?  What have I done wrong?   P.S.  was the tutorial that helped me. Is the Ministry of Magic unable to detect illegal time-tampering? Since Hermione already admitted that they were breaking the Law. Would it be safe to conclude that the Ministry cannot instantly (by magic) detect illegal time-tampering?  (Both before and during the events of Prisoner of Azkaban.)     “Hermione,” said Harry suddenly, “what if we — we just run in    there and grab Pettigrew —”       “No!” said Hermione in a terrified whisper. “Don’t you understand?    We’re breaking one of the most important wizarding laws!    Nobody’s supposed to change time, nobody! You heard Dumbledore,    if we’re seen —”       — Prisoner of Azkaban, chapter 21 (Hermione’s Secret) Any way to do DISTINCT ON? I'm trying to create a query like this:  SELECT DISTINCT ON (field1, field2) field1, field2, field3 FROM table1   But can't figure out how to get DISTINCT ON narrowed down to a few fields in Drupal like that. Calling $query-&gt;distinct() just seems to structure the query like this:  SELECT DISTINCT field1, field2, field3 FROM table1   I did figure out a hacky way to add what I want by adding an expression before I add any fields like this:  $query-&gt;addExpression('DISTINCT ON (field1, field2) field1', 'field1');   Which creates:  SELECT DISTINCT ON (field1, field2) field1 as field1, field2, field3 FROM table1   I'm looking for a better way to this ? Over 20GB of disk space is gone? System drive, OS is Windows 7 x64 SP1 Ultimate.    Windows Explorer shows 100GB of used space.  TreeSizeFree shows 75GB of used space.  Total Commander and FAR confirm TreeSizeFree's measurements (counting hidden files).  Shadow copy is using up to 5GB with the current usage of 1.36GB.  Running FAR from Win7 PE shows the same.  Checkdisk shows no bad sectors. Disk is an OCZ SSD.  SMART monitor suggests SSD condition is perfect.    Where is the rest of space gone? Oracle 11g: increasing buffer cache with AMM On a 2-node RAC we have enabled Automatic Memory Management. The advisor views indicate that increasing the buffer cache by 4 GB will half the physical reads, and we have 4 GB to give.   How must we do this? By increasing memory_target and letting Oracle grab more memory for the buffer cache? Or by explicitly setting a value for db_cache_size (which now is zero)? Live USB "Check disk for defects” finds defects but doesn't list them I downloaded the iso file for XUbuntu. I created a live usb using Pen Drive Linux. I turned on my computer, booted to the XUbuntu installation screen, and selected "check disk for defects".  A minute later, it says that it found one defect. How do I figure out what this defect is? How can we improve the inconsistent tagging of the questions relating to the recent uproar and associated issues? Question description  There are many questions (~250 in the last five weeks) relating to      sometimes they are about licensing, legal issues, , , , etc.  These questions relate to the same growing polarization between community and Stack&nbsp;Exchange staff. But, it is not easy to search or filter them because the tags are not uniform for those questions, they do not have the same tags.  Could we group all these posts together by some common tag (new or not)? (in addition, maybe we should create less of these questions, they tend to become noise now, water down the core message, and it is ).    Relevance  Overview of current tags (aside from the discussion tag) for the first ten  (           ) questions relating to  (ordered by relevance)                              1   2   3   4   5   6   7   8   9   10     moderators              x           x   x   x     community               x           x   x     etiquette                   x     users                       x     company                     x     moderation                      x     code-of-conduct                     x       x       x     deleted-questions                               x     legal                                                   x   These tags are obviously not the same while it is arguably the same topic (it is even for the same, specific, search term) .  Instead of using multiple searches one might wish to control tracking these question by adding some single relevant tag to watched tags or ignore tags. But, this is difficult when they do not use the same tag. And in the case of ignoring one might ignore too much when the tag is not specific.  Another indicator that these posts need consistent tagging is the fact that there exist highly upvoted answers that function as an archive for these questions (see  and ). But it is only a hack/workaround for the absence of a common tag; they are not an optimal solution.    Why now?  In an older question () it was suggested to create a specific tag. That was rejected at that point. But, now we are several weeks, and many many questions, further. The situation is more escalated than what might have foreseen at that point. The overview becomes a mess and something needs to be done.  See the bump in the image below which indicates that something is 'going on' and it entails a large fraction of the current post. (obtained from ) Table of Contents with Chapter I'm attempting to modify the Table of Contents in my document. Currently, chapter one in my document is listed as   1   Introduction   What I would like to see is  Chapter 1   Introduction   Seems like an easy enough thing to ask for, but can't seem to find a good way to do this. Any feedback would be most appreciative. Dual Canadian and British citizen - healthcare coverage in the UK? I want to know if I am entitled to medical assistance in the UK while visiting for 3 weeks in June. I am travelling on my Canadian passport since my UK one is outdated. How to send email from MySQL 5.1 How can angular velocity be constant even when there is a torque by friction? A cylinder at rest lying on a rough ground is given an impulse which imparts a translational velocity (no angular velocity) to it. The question goes ahead with finding time after which rolling starts etc. etc.  But I have another question: The friction from the ground will decrease the translational velocity but increase the angular velocity (as the torque of friction will be in the direction of rolling). After some time, the translational velocity will become equal to angular velocity and hence pure rolling will start.  After this time work done by friction will be 0 as the point of contact is not moving and hence translational velocity will be constant. Now my doubt is that, when translational velocity is constant, it implies angular velocity will also be constant (as translational velocity is a multiple of angular velocity). But the torque from friction (about the centre of mass) will not be zero which means angular velocity will not be constant. In some book where there was the same problem it was written friction will vanish. How can friction vanish? How can anguluar velocity be constant even when there is a torque by friction? Can't maximise Minecraft window I was playing in Minecraft in full screen for a while (toggling using F11) and then after a while, I went back to windowed mode (I don't like playing in full screen, I was just testing the functionality of it for... reasons).  However, when I went to maximize the window (not full-screen) I realized the maximize box in the corner had become disabled. I fiddled with full screen a bit more, toggling it in the menu options as well as toggling it with F11, but this had no effect. Restarting Minecraft (closing it completely and re-opening, not just quitting to menu) did fix it however.  Does anyone know what causes this issue, and if restarting Minecraft is the only way to fix it? How to get the size of a JavaScript object? Data Not Backed Up, Partition Type: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF I was trying to install Linux on my MacBook for class when I bricked my computer, which now in an unbootable state.   I made my partition too small, so I was going to delete and create a larger one. However, Disk Utility did not allow me to delete the small partition. I followed the instructions from   However, not only was I still unable to delete it, but upon restarting I realized my primary partition (located on the same disk) changed into FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF, and I had no options to boot.  (I am sure I performed the command on the correct disk and partition)  I saw some similar threads, but my main bootable drive is the one that got corrupt.   I don't want to lose any data. I'm not the most terminal savvy, so ANY help is appreciated, and I will kindly provide any additional information!  (Disk 0, partition 2 is my main partition, and that only one I care about)  Below are the results of  $ diskutil list and $ gpt -r show disk0.        UPDATE: :  I have followed @klanomath 's instructions. At the last step I received the following error:  Checking prerequisites Checking the partition list Checking for an EFI system partition Checking the EFI system partition's size Checking the EFI system partition's file system Problems were found with the partition map which might prevent booting Error: -69766: The partition map needs to be repaired because there's a problem with the EFI system partition's file system Underlying error: 8: POSIX reports: Exec format error    FINAL UPDATE: SUCCESS!  I just wanted thank @klanomath for helping me through this entire process. He spent 11 hours TeamViewing with me until not only my files were accessible, but until I could access my computer as could before this whole debacle (and this was after 5 hours of email correspondence).   To any future reader with this problem: PLEASE don't give up, it can be fixed! Is it ever bad to use \left and \right? For mathematics, is it ever disadvantageous to use \left(  and \right)  in equations?  I can't see any way that doing this would hinder the typesetting, so why isn't () just converted into \left( \right) automatically? This would save a lot of typing.  Cheers! What is the best way to tokenize/split a NSString in Objective-C? Can a regular salaried (w2) employee opt to pay quarterly taxes? As a consultant, I got used to paying quarterly taxes. Now that I'm a regular w2 salaried employee, I'm subject to normal withholding on each pay statement. I would like to keep making exact quarterly payments instead of having a (generally incorrect) amount held back each paycheck.   I haven't been able to find any information on the 1040-es that would make me think I'm ineligible to do so, but I suspect that it may be the case. I'd have to stop paycheck withholdings by updating my w4 to either have a high number of exemptions or mark myself as exempt from taxes, which I assume is where the rub lies.   So, as a regular salaryman, is it possible for me to pay taxes exclusively through quarterly payments in lieu of traditional withholdings? Representing every positive rational number in the form of $(a^n+b^n)/(c^n+d^n)$ About a month ago, I got the following :      For every positive rational number $r$, there exists a set of four positive integers $(a,b,c,d)$ such that    $$r=\frac{a^\color{red}{3}+b^\color{red}{3}}{c^\color{red}{3}+d^\color{red}{3}}.$$      For $r=p/q$ where $p,q$ are positive integers, we can take    $$(a,b,c,d)=(3ps^3t+9qt^4,\ 3ps^3t-9qt^4,\ 9qst^3+ps^4,\ 9qst^3-ps^4)$$   where $s,t$ are positive integers such that $3\lt r\cdot(s/t)^3\lt 9$.      For $r=2014/89$, for example, since we have $(2014/89)\cdot(2/3)^3\approx 6.7$, taking $(p,q,s,t)=(2014,89,2,3)$ gives us $$\frac{2014}{89}=\frac{209889^3+80127^3}{75478^3+11030^3}.$$   Then, I began to try to find every positive integer $n$ such that the following proposition is true :   Proposition : For every positive rational number $r$, there exists a set of four positive integers $(a,b,c,d)$ such that $$r=\frac{a^\color{red}{n}+b^\color{red}{n}}{c^\color{red}{n}+d^\color{red}{n}}.$$  The followings are what I've got. Let $r=p/q$ where $p,q$ are positive integers.   For $n=1$, the proposition is true. We can take $(a,b,c,d)=(p,p,q,q)$. For $n=2$, the proposition is false. For example, no such sets exist for $r=7/3$. For even $n$, the proposition is false because the proposition is false for $n=2$.   However, I've been facing difficulty in the case of odd $n\ge 5$. I've tried to get a similar set of four positive integers $(a,b,c,d)$ as the set for $n=3$, but I have not been able to get any such set. So, here is my question.     Question : How can we find every odd number $n\color{red}{\ge 5}$ such that the following proposition is true?      Proposition : For every positive rational number $r$, there exists a set of four positive integers $(a,b,c,d)$ such that $$r=\frac{a^n+b^n}{c^n+d^n}.$$   Update : I posted this question on .  Added :  asks the case $n=3$. Is it possible to read a .PST file using C#? I would like to do this as a standalone application, not as an Outlook addin (if that is possible).   If have seen     to this mention  but I am looking to do this programmatically in C#.  I have looked at the  namespace but that appears to be just for Outlook addins.  appears to be able to read PST files, but this is in C (sorry Joel, I didn't ).  Any help would be greatly appreciated, thanks!  EDIT:   Thank you all for the responses! I accepted Matthew Ruston's response as the answer because it ultimately led me to the code I was looking for. Here is a simple example of what I got to work (You will need to add a reference to Microsoft.Office.Interop.Outlook):  using System; using System.Collections.Generic; using Microsoft.Office.Interop.Outlook;  namespace PSTReader {     class Program {         static void Main () {             try {                 IEnumerable&lt;MailItem&gt; mailItems = readPst(@"C:\temp\PST\Test.pst", "Test PST");                 foreach (MailItem mailItem in mailItems) {                     Console.WriteLine(mailItem.SenderName + " - " + mailItem.Subject);                 }             } catch (System.Exception ex) {                 Console.WriteLine(ex.Message);             }             Console.ReadLine();         }          private static IEnumerable&lt;MailItem&gt; readPst(string pstFilePath, string pstName) {             List&lt;MailItem&gt; mailItems = new List&lt;MailItem&gt;();             Application app = new Application();             NameSpace outlookNs = app.GetNamespace("MAPI");             // Add PST file (Outlook Data File) to Default Profile             outlookNs.AddStore(pstFilePath);             MAPIFolder rootFolder = outlookNs.Stores[pstName].GetRootFolder();             // Traverse through all folders in the PST file             // TODO: This is not recursive, refactor             Folders subFolders = rootFolder.Folders;             foreach (Folder folder in subFolders) {                 Items items = folder.Items;                 foreach (object item in items) {                     if (item is MailItem) {                         MailItem mailItem = item as MailItem;                         mailItems.Add(mailItem);                     }                 }             }             // Remove PST file from Default Profile             outlookNs.RemoveStore(rootFolder);             return mailItems;         }     } }   Note: This code assumes that Outlook is installed and already configured for the current user. It uses the Default Profile (you can edit the default profile by going to Mail in the Control Panel). One major improvement on this code would be to create a temporary profile to use instead of the Default, then destroy it once completed.