My purpose was to make 2D list by * list2 = [[False]*2]*3 #[[False,False],[False,False],[False,False]] list3 = [[False]*2 for _ in range(3)] #same as list2 list2[0][0] = True # [[True, False], [True, False], [True, False]] list3[0][0] = True # [[True, False], [False, False], [False, False]]  list3 works well but list2 doesn't. list2 is affected by 'x' of list2[z][x]. What happened?
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?
Assigning CRS to Lat/Lon in R giving error: "Geographical CRS given to non-conformant data" Prevent mail being marked as spam Clickable Table Footnote I'm trying to have some clickable footnotes within tables. I tried using \footnote{}, it does create a link but there's no footnote text associated with it. \footnotemark[number] along with \footnotetext[]{} does create a fotenote but then there's no hyperlink. (I would like to make it clear that I'm trying to have footnotes at the bottom of the page and not footnotes within the table.)  Here's a small code snippet:  \documentclass{report}  \usepackage{hyperref} \begin{document}  \begin{table}[h!]     \centering     \begin{tabular}{|r|r|r|}         \hline         A\footnote{Test!} &amp; B\footnotemark[4] &amp; C\footnotemark[5]\\         \hline         123 &amp; Tim &amp; Jane\\         \hline         456 &amp; Tom &amp; Jung\\         \hline     \end{tabular}     \caption{A table} \end{table}  This is a clickable footnote\footnote{You clicked me!}.  \footnotetext[4]{This is B} \footnotetext[5]{This is C}  \end{document} Does the output bypass capacitor of an LM7805 double as a decoupling capacitor? I'm using a 5v linear regulator (specifically an LM7805) that outputs directly to an ATMEGA328P. According to the  (page 23) input and output bypass capacitors should be used, as seen below, to tame peaks and ensure stability.    It is good practice to also include a decoupling capacitor in front of an IC, in this case an ATMEGA328. Does the 0.1μF capacitor on the output side of the LM7805 act as a decoupling capacitor if the regulator feeds into the IC directly after the output bypass capacitor? Something special about energy eigenstates when it comes to time evolution? A particle is subject to an infinite square well potential with  $$V(x)= \begin{cases}  0  &amp;   −a \lt x \lt a\\   \infty &amp;  \,\,\,\,\text{otherwise} \end{cases}$$  At a time $t=0$ its wavefunction is given by $$\psi(x, t=0)=\frac{1}{\sqrt{5a}}\cos\left(\frac{\pi x}{2a}\right)+\frac{2}{\sqrt{5a}}\sin\left(\frac{\pi x}{a}\right)$$       (a) What are the possible results of an energy measurement at $t = 0$, and with what probabilities?     Re-writing the terms in $\psi(x,t=0)$ as $$u_1(x)=a^{-1/2}\cos\left(\frac{\pi x}{2a}\right)\qquad \text{&amp;} \qquad u_2(x)=a^{-1/2}\sin\left(\frac{\pi x}{a}\right)$$ such that $$\psi(x,t=0)= \frac{1}{\sqrt{5}}u_1(x)+\frac{2}{\sqrt{5}}u_2(x)$$ with energies $$E_1=\frac{\hbar^2 \pi^2}{8ma^2}\qquad \text{&amp;} \qquad E_2=\frac{\hbar^2 \pi^2}{2ma^2}$$ and probabilities $$P(E_1)=\frac15 \qquad \text{&amp;} \qquad P(E_2)=\frac45$$       (b) If no measurement is performed, what is the wavefunction $\psi(x, t)$ at all times $t$? What are the possible energies and their probabilities if a measurement is first performed at time $t$?     At a time $t$ the wavefunction is given by $$\psi(x, t=0)=\frac{1}{\sqrt{5a}}\cos\left(\frac{\pi x}{2a}\right)\exp\left(\frac{-i E_1 t}{\hbar}\right)+\frac{2}{\sqrt{5a}}\sin\left(\frac{\pi x}{a}\right)\exp\left(\frac{-i E_2 t}{\hbar}\right)$$    The problem is that I cannot answer the second part of the question (b).    The answer states that:      Because the two terms are energy eigenstates, the relative probabilities do not change and are as in the previous part.     I have some questions about the above statement: why does an "energy eigenstate" mean that the probablities don't change with time? Or, put in another way, does a "momentum eigenstate" (for example) have constant relative probabilities when measured at any time?   The answer seems to be implying there is something special about energy eigenstates when it comes to time evolution. The eigenvalues of energy measurements don't seem to change regardless of how many times you measure them, and no matter how long you wait until you measure them. I'm not sure if this is the case, but could someone please explain why all quantum operators (except Hamiltonian) do not exhibit this behaviour. Closed-Form Solution to Infinite Sum Can I configure Ubuntu to never install a specific package even if it is required by another package I install? Let $F$ be a field and $F[x]$ a polynomial ring. Let $p(x)$ be an irreducible polynomial.  Show that $\gcd(p(x),q(x)) = 1\Longrightarrow \exists r(x),s(x)$ such that $r(x)p(x)+s(x)q(x) = 1$.  I know the proof for Bezout's identity for , but this proof uses the notion of absolute value, which cannot be applied to a polynomial ring.   I am thinking about a way to prove the statement: Use the Euclidean algorithm to compute $\gcd(p(x),q(x))$ and show that the result is $1$, and somehow go backwards to obtain $r(x)p(x)+s(x)q(x) = 1$, but it is a bit messy, and I'm not yet able to see it completely.  Please offer some help. If you have some other methods, that would be great, too. I have a problem analysing this sentence from the point of finite/nonfinite clauses, clause elements and their functions:     He does not want to destroy his parents' dream of him achieving a Cambridge degree.   I am especially interested in the: dream of him achieving a Cambridge degree.  I know that 'achieving a Cambridge degree' is a non-finite -ing participle clause. However what is its function? And what is the function of 'of him'? Is it a postmodification? Isometric  Left Inverse Adjoint Is it true that: $$T\text{ isometric}\iff T^*\text{ left inverse}$$ Obviously: $$\text{"}\Rightarrow\text{": }\langle x,\tilde{x}\rangle=\langle Tx,T\tilde{x}\rangle=\langle x,T^*T\tilde{x}\rangle$$ $$\text{"}\Leftarrow\text{": }\langle Tx,T\tilde{x}\rangle=\langle x,T^*T\tilde{x}\rangle=\langle x,\tilde{x}\rangle$$ My problem is that I'm not sure about if the adjoint is left inverse then the operator necessarily is bounded so that domain issues might come into play... How can I fix a 404 Error when using a PPA or updating my package lists? PPA seems to be constantly offline. Whenever I use sudo apt-get update, this error is shown:  W: Failed to fetch http://ppa.launchpad.net/ 404  Not Found   How do I fix these errors? How old is too old for a PhD? Are there any age limits (formal, informal, or guidelines) that schools use when deciding to accept someone into a PhD program? I'm most curious about the upper age limits. For example, will most schools accept someone in their 40's? How about their 50's? How to move windows that open up offscreen? I have a dual monitor setup, and I recently played around with the positioning settings, and some of my single window applications do the favour of preserving where they were last closed, and opening in the same position later. Unfortunately, that now places them out of the viewable area of my screens!  Is there some way to force a particular window into the viewable area? Filling cells with sequential numbers in an Excel (2003) macro I need to fill an excel column with a sequential series, in this case from -500 to 1000.  I've got a macro to do it, but it takes a lot of lines for something that seems like it should be a single function [something like FillRange(A2:A1502, -500, 1000, 1)].  But if that function exists, I can't find it.  Is the following as simple and elegant as it gets?  'Draw X axis scale Cells(1, 1).Value = "mV" Cells(2, 1).Value = -500 Cells(3, 1).Value = -499 Cells(4, 1).Value = -498  Dim selection1 As Range, selection2 As Range  Set selection1 = Sheet1.Range("A2:A4") Set selection2 = Sheet1.Range("A2:A1502")  selection1.AutoFill Destination:=selection2 How to do "Files to store without compression" in 7-zip? Is there any way to selectively prevent certain file types from compression in 7-zip, like in WinRAR?  I'm trying to compress a huge folder (many gigabytes), and I don't want the already-compressed files (e.g. ZIP files) to be re-compressed -- they should be stored without compression. Can I run an HTTP GET directly in SQL under MySQL? I'd love to do this:  UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n;   Is there code available to do this? I known this should be possible as the  include an example of adding a function that does a DNS lookup.  MySQL / windows / Preferably without having to compile stuff, but I can.  (If you haven't heard of anything like this but you would expect that you would have if it did exist, A "proly not" would be nice.)  EDIT: I known this would open a whole can-o-worms re security, however in my cases, the only access to the DB is via the mysql console app. Its is not a world accessible system. It is not a web back end. It is only a local data logging system Uses of the 3D Cursor I am trying to make a snowball that triggers a command when it hits a player in 1.15, but I don't know how to do that. When I do execute at @e[type=snowball] run gamemode spectator @a[distance=..2] it only runs the command if it goes right next to them. Why was Enterprise on a five-year mission in TOS? There is a small difference between intro texts in TOS:     Space: the final frontier. These are the voyages of the starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.   and in TNG:     Space: the final frontier. These are the voyages of the starship Enterprise. Its continuing mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no one has gone before.   (emphasis mine)  It's pretty obvious that no man was changed to no one to include women. But, is there any explanation why was five-year changed to continuing? Also, why was it a five-year mission at all?  My only assumptions are:   Gene Roddenberry hoped to get funding to run the show for 5 seasons. Gene Roddenberry just made up a number without any special meaning. Gene Roddenberry was a .   Is there any official explanation, in universe or not? The canonical way to return multiple values in languages that support it is often . Option: Using a tuple Consider this trivial example: def f(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return (y0, y1, y2)  However, this quickly gets problematic as the number of values returned increases. What if you want to return four or five values? Sure, you could keep tupling them, but it gets easy to forget which value is where. It's also rather ugly to unpack them wherever you want to receive them. Option: Using a dictionary The next logical step seems to be to introduce some sort of 'record notation'. In Python, the obvious way to do this is by means of a dict. Consider the following: def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return {'y0': y0, 'y1': y1 ,'y2': y2}  (Just to be clear, y0, y1, and y2 are just meant as abstract identifiers. As pointed out, in practice you'd use meaningful identifiers.) Now, we have a mechanism whereby we can project out a particular member of the returned object. For example, result['y0']  Option: Using a class However, there is another option. We could instead return a specialized structure. I've framed this in the context of Python, but I'm sure it applies to other languages as well. Indeed, if you were working in C this might very well be your only option. Here goes: class ReturnValue:   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return ReturnValue(y0, y1, y2)  In Python the previous two are perhaps very similar in terms of plumbing - after all { y0, y1, y2 } just end up being entries in the internal __dict__ of the ReturnValue. There is one additional feature provided by Python though for tiny objects, the __slots__ attribute. The class could be expressed as: class ReturnValue(object):   __slots__ = [&quot;y0&quot;, &quot;y1&quot;, &quot;y2&quot;]   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  From the :  The __slots__ declaration takes a sequence of instance variables and reserves just enough space in each instance to hold a value for each variable. Space is saved because __dict__ is not created for each instance.  Option: Using a  (Python 3.7+) Using Python 3.7's new dataclasses, return a class with automatically added special methods, typing and other useful tools: @dataclass class Returnvalue:     y0: int     y1: float     y3: int  def total_cost(x):     y0 = x + 1     y1 = x * 3     y2 = y0 ** y3     return ReturnValue(y0, y1, y2)  Option: Using a list Another suggestion which I'd overlooked comes from Bill the Lizard: def h(x):   result = [x + 1]   result.append(x * 3)   result.append(y0 ** y3)   return result  This is my least favorite method though. I suppose I'm tainted by exposure to Haskell, but the idea of mixed-type lists has always felt uncomfortable to me. In this particular example the list is -not- mixed type, but it conceivably could be. A list used in this way really doesn't gain anything with respect to the tuple as far as I can tell. The only real difference between lists and tuples in Python is that lists are , whereas tuples are not. I personally tend to carry over the conventions from functional programming: use lists for any number of elements of the same type, and tuples for a fixed number of elements of predetermined types. Question After the lengthy preamble, comes the inevitable question. Which method (do you think) is best?