I'm trying to initialize a list of empty dictionaries to be filled up later.  Tried using the multiplication operand:  x=2*[{}]   This apparently creates a list with two references that point to the same dictionary object, so that each thing I do to each dictionary gets done to all:  &gt;&gt;&gt;  &gt;&gt;&gt; x=2*[{}] &gt;&gt;&gt; x [{}, {}] &gt;&gt;&gt; x[0] is x[1] True &gt;&gt;&gt; x[0].update({'foo':[]}) &gt;&gt;&gt; x [{'foo': []}, {'foo': []}] &gt;&gt;&gt;  &gt;&gt;&gt;  &gt;&gt;&gt; y=2*[{}] &gt;&gt;&gt; y [{}, {}] &gt;&gt;&gt; y[0]['bar']=[] &gt;&gt;&gt; y [{'bar': []}, {'bar': []}] &gt;&gt;&gt;  &gt;&gt;&gt;  &gt;&gt;&gt; w=2*[{}] &gt;&gt;&gt; w [{}, {}] &gt;&gt;&gt; w[1][1]=1 &gt;&gt;&gt; w [{1: 1}, {1: 1}] &gt;&gt;&gt;    If I assign without the multiplication operand, then I get the behaviour I want:  &gt;&gt;&gt; z=[{},{}] &gt;&gt;&gt; z [{}, {}] &gt;&gt;&gt; z[1][1]=1 &gt;&gt;&gt; z [{}, {1: 1}] &gt;&gt;&gt;    But in my actual code I do not know before runtime how big the list will be!  So, two questions: Is this expected, or a bug in the language? How do I initialize a list to be like the z variable without knowing its size when I write the code?  Context:  Python 3.3.4. Using xlrd to parse a MS Excel spreadsheet. The spreadsheet has several header lines spread whithin the data, each changing the meaning of the data between it and the next header line. I want to loop over the lines filling each dict with the data using the correct (nearest above) headers as keys.  A possible workaround would be to hardcode the list length to the number of lines of this spreadsheet, but that introduces a maintenance issue of requiring a code change every time that number changes.  Thanks for any help.
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?
Why do we call a 1/2 spin particle satisfying the Dirac equation a , and not a  or a ? Fields - Proof that every multiple of zero equals zero This is one of my first proofs about fields. Please feed back and criticise in every way (including style and details).  Let $(F, +, \cdot)$ be a field. Non-trivially, $\textit{associativity}$ implies that any parentheses are meaningless. Therefore, we will not use parentheses. Therefore, we will not use $\textit{associativity}$ explicitly.  By $\textit{identity element}$, $F \ne \emptyset$. Now, let $a \in F$. It remains to prove that $0a = 0$. \begin{equation*} \begin{split} 0a &amp;=  0a +  0      &amp;&amp; \quad \text{by }\textit{identity element }(+    ) \\    &amp;=  0a +  a + -a &amp;&amp; \quad \text{by }\textit{inverse element  }(+    ) \\    &amp;=  0a + 1a + -a &amp;&amp; \quad \text{by }\textit{identity element }(\cdot) \\    &amp;= (0 + 1)a + -a &amp;&amp; \quad \text{by }\textit{distributivity   }        \\    &amp;= (1 + 0)a + -a &amp;&amp; \quad \text{by }\textit{commutativity    }(+    ) \\    &amp;=      1 a + -a &amp;&amp; \quad \text{by }\textit{identity element }(+    ) \\    &amp;=        a + -a &amp;&amp; \quad \text{by }\textit{identity element }(\cdot) \\    &amp;=  0            &amp;&amp; \quad \text{by }\textit{inverse element  }(+    ) \end{split} \end{equation*} QED  PS: Is "Let $(F, +, \cdot)$ be a field." ok? Besides, I would not want to call $F$ a field, because $F$ is just a set. Also, what do you think about using adverbs like "Now"? How would you have said the associativity-thing? Dual edge detector I am designing a hobby project that will run on a battery so I am trying to reduce power consumption. The SoC I am using has the ability to go into a deep sleep mode where it consumes very little power, and then can be interrupted by a falling edge on a pin.  I want to generate a high-low-high pulse when the state of a reed switch changes in either direction. I have been reading a lot and it seems that a one-shot monostable circuit can be built from a couple of transistors and an RC circuit to generate an output pulse when an edge is detected. I understand how that works. However, I can't figure out the best way to also pulse on the opposite edge.  One thought, was to just combine two one-shots that are configured to trigger on rising and falling edges respectively, and use the transistors at the output to pull the common pull-up low (kind of like a NOR gate).  Since I am a hobbyist, I am mostly using passive components. What is the "real" way of doing this in a low-power configuration using logic devices?  Edit: I figure I should mention something about the timing requirements. Normally the reed switch will be either open or closed for many seconds at minimum before changing states.  Edit: Here is an example of the circuit I was using for detecting only the falling edge:    And here is the ~20ms pulse it was producing for ~200ms button press simulating the reed switch (Channel 1 is Vbe for T1 and Channel 2 is measured at RST): What's the meaning of a dot before a command in shell? While following android eclipse debug tutorial, I encounter following commands.  cd /path/to/android/root  . build/envsetup.sh  lunch 1     make        emulator   My problem is what the dot before build/envsetup.sh means? Why does the version of Java verified by Oracle differ from the version shown at the command line? Questions  Why do versions differ?   Should we trust Oracle's verification routine?    In some cases, the  is different from the version shown at the command line.   Example    That example, in detail  According to Oracle in the browser:    Java 7 Update 9   According to the Java Console:   Java Plug-in 10.9.2.05 Using JRE version 1.7.0_09-b05 Java HotSpot(TM) 64-Bit Server VM   According to the java command:   sh-3.2$ java -version java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b58) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b02, mixed mode) How do I duplicate a whole line in Emacs? ffmpeg - how to apply filters without losing quality Alternative to LibreOffice Base for Ubuntu Mann-Whitney U test with unequal sample sizes I came across the :    Which states:     $\pi$ Pi      Pi is an infinite, nonrepeating $($sic$)$ decimal - meaning that   every possible number combination exists somewhere in pi.  Converted   into ASCII text, somewhere in that infinite string of digits is the   name of every person you will ever love, the date, time and manner    of your death, and the answers to all the great questions of    the universe.   Is this true? Does it make any sense ? Can “whose” refer to an inanimate object? Keyboard shortcut to autocomplete the user in comments Are "beginner questions" allowed on Stack Overflow? I noticed that  (about basic  syntax) received a lot of downvotes as soon as I posted it. Is there any specific policy against the posting of questions with "obvious" answers on Stack Overflow?  I'm unclear as to why questions with "obvious" answers aren't usually well-received by the community - are beginner questions considered harmful for some reason? ("Obvious" is a relative term, of course - this type of question would be helpful to anyone who was learning C# for the first time, but it wouldn't be helpful to an experienced C# developer.) Changing content of footline in beamer How is it possible to set a specific text in the footline of the slides in beamer? In my case, author names and the title are shown. Instead I'd like to show the conference name and country.  \documentclass{beamer} \usetheme{CambridgeUS}  \author{Elena Piper, Amina Shahid, April Fiorese} \title{Evaluating the Change of Performance Metrics for Key ABS}  \begin{document} \maketitle  \end{document} Determine the size of a C++ array programmatically? This question was inspired by a similar question:   My question is a little different:  Is there any way to determine the size of a C++ array programmatically?  And if not, why?  Every function I've seen that takes an array also requires an integer parameter to give it the size.  But as the linked question pointed out, delete[] must know the size of the memory to be deallocated.  Consider this C++ code:  int* arr = new int[256]; printf("Size of arr: %d\n", sizeof(arr));   This prints "Size of arr: 4", which is just the size of the pointer.  It would be nice to have some function which prints 256, but I don't think one exists in C++.  (Again, part of the question is why it doesn't exist.)  Clarification: I know that if I declared the array on the stack instead of the heap (i.e. "int arr[256];") that the sizeof operator would return 1024 (array length * sizeof(int)). Who owns R2-D2 & C-3PO in the Prequel trilogy? Is there any concrete evidence that Anakin officially owned R2-D2 or C-3PO?  I found this episode of Star Wars: Clone Wars that shows it, but it's fairly vague... Combinatorial Proof Question: Vandermonde convolution identity I'm really iffy on combinatorial proofs in general and now that there is a sum, it's just confused me even more. Can someone try and walk me through this proof?  $$ \binom{m + n}{r} = \sum_{k=0}^r \binom{m}{k}\binom{n}{r - k} $$ Compute the moment generating function of $Y = X_1X_2 + X_1X_3 + X_2X_3$ The ending I got is :      the genocide   When I reset my file, my past choices still take effect. I want to start a clean run.  I don't want to buy the game again, what do I do? Decrypt all RSA ciphertexts if you can break 1% of them