Why does len(grid) vs for i in range(len(grid)) make a difference? For the code below, which is used for Leetcode #64 Minimum Path Sum, I tried to make the cache grid using &quot; len(grid)&quot; and it does not work for all test cases, but if I do &quot;for i in range(len(grid))&quot; it works perfectly. I'm wondering why this makes a difference if the grid has the same dimensions either way. My code works for the first 2 cases but fails at the third, the code that uses range is accepted in Leetcode. Thank you. class Solution:     def minPathSum(self, grid: list) -&gt; int:         # cash = [[-1] * len(grid[0])] * len(grid)         cash = [[-1] * len(grid[0]) for i in range(len(grid))]         return self.recursion(grid, 0, 0, cash)      def recursion(self, grid, y, x, cash):          # first we check if the space is valid         if self.check(grid, y, x) is not True:             return 0          # then we check if that space has already been cached, if it has, we just return that space         if cash[y][x] != -1:             return cash[y][x]          # this is where the space currently is on the grid         current = grid[y][x]         # now check if we are currently at the rightmost or bottommost perimeters of the grid         if y == len(grid) - 1:  # if at rightmost, have to go down             cash[y][x] = current + self.recursion(grid, y, x + 1, cash)         elif x == len(grid[0]) - 1:  # at bottommost, have to go right             cash[y][x] = current + self.recursion(grid, y + 1, x, cash)         else:  # if the current value is not at a bottom or right perimeter, keep going             cash[y][x] = current + min(self.recursion(grid, y, x + 1, cash),  # compare the right block                                        self.recursion(grid, y + 1, x, cash))  # to the down block         print(cash)         return cash[y][x]      # check if this space exists in the grid using the grid boundaries     def check(self, grid, y, x):         return len(grid) &gt; y &gt;= 0 and len(grid[0]) &gt; x &gt;= 0   grid = [[1,3,1],[1,5,1],[4,2,1]] print(Solution().minPathSum(grid=grid))  grid = [[1,2,3],[4,5,6]] print(Solution().minPathSum(grid=grid))  grid = [[1,2],[1,1]] print(Solution().minPathSum(grid=grid))
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?
My Android device screen got broken and I can't see what I'm doing. That's the only wrong thing with my device, the rest is apparently working OK. Is there any way to send my device screen to my computer? I don't want to work blindly anymore! How are digital movies sent to a movie theater? For many years, movies were stored on rolls of film that were physically mailed to theaters. Now, most theaters project their movies digitally. But how are these digital movies sent to the theater?   Do they mail a hard drive to the theater? Do they give the theater a username and password to a super secret website where they can download it? How does it get there? Adding coordinate system to layout in QGIS composer? I would like to know if there is a way to add a dynamic coordinate system field into a QGIS composer layout.  I can use an expression to add many items such as document name, file path, etc but I can;t seem to figure out how to add the coordinate system? Rotate group of objects over an edge Batch file to delete files older than N days I am looking for a way to delete all files older than 7 days in a batch file.  I've searched around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the task.  Similar things can be  in just a couple lines of code. It seems that something at least remotely easy could be done for batch files in Windows. I'm looking for a solution that works in a standard Windows command prompt, without any extra utilities. Please no PowerShell or Cygwin either. Is having a skills bar chart on a resume a good idea? Attaching event handlers in Visual Basic .NET Should flagging a question for closure prevent close-voting? Naming threads and thread-pools of ExecutorService Meaning of the word "axiom" Thus, axioms are propositions we assume to be true and we use them in an axiomatic theory as premises to infer conclusions, which are called "theorems" of this theory.  For example, we can use the  to prove theorems of arithmetic.  This is one meaning of the word "axiom". But I recognized that the word "axiom" is also used in quite different contexts.  For example, a group is defined to be an algebraic structure consisting of a set $G$, an operation $G\times G\to G: (a, b)\mapsto ab$, an element $1\in G$ and a mapping $G\to G: a\mapsto a^{-1}$ such that the following conditions, the so-called group axioms, are satisfied:   $\forall a, b, c\in G.\ (ab)c=a(bc)$, $\forall a\in G.\ 1a=a=a1$ and $\forall a\in G.\ aa^{-1}=1=a^{-1}a$.      Why are these conditions (that an algebraic structure has to satisfy to be called a group) called axioms? What have these conditions to do with the word "axiom" in the sense specified above? I am really asking about this modern use of the word "axiom" in mathematical jargon. It would be very interesting to see how the modern use of the word "axiom" historically developed from the original meaning.   Now, let me give more details why it appears to me that the word is being used in two different meanings:  As peter.petrov did, one can argue that group theory is about the conclusions one can draw from the group axioms just as arithmetic is about the conclusions one can draw from the Peano axioms. But in my opinion there is a big difference: while arithmetic is really about natural numbers, the successor operation, addition, multiplication and the "less than" relation, group theory is not just about group elements, the group operation, the identity element and the inverse function. Group theory is rather about models of the group axioms. Thus: The axioms of group theory are not the group axioms, the axioms of group theory are the axioms of set theory.  Theorems of arithmetic can be formalized as sentences over the signature (a. k. a. language) $\{0, s, +, \cdot\}$, while theorems of group theory cannot always be formalized as sentences over the signature $\{\cdot, 1, ^{-1}\}$. Let me give an example: A typical theorem of arithmetic is the case $n=4$ of Fermat's last theorem. It can be formalized as follows over the signature $\{0, s, +, \cdot\}$: $$\neg\exists x\exists y\exists z(x\not = 0\land y\not = 0\land z\not = 0\quad\land\quad x\cdot x\cdot x\cdot x + y\cdot y\cdot y\cdot y = z\cdot z\cdot z\cdot z).$$ A typical theorem of group theory is  which states that for any finite group G, the order of every subgroup H of G divides the order of G. I think that one cannot formalize this theorem as a sentence over the "group theoretic" signature $\{\cdot, 1, ^{-1}\}$; or can one? Automatically switch gpu graphics driver when gaming I have installed Ubuntu GNOME 15.10. I installed the nvidia tested proprietary driver and then I restarted. Afterr that I selected as primary GPU the Intel driver for normal use. However, when I enter a steam game(Portal) the graphics is bad so In order to play normal I have to switch manually to the nvidia driver again and reboot again. After the game I have to manually select as primary driver the Intel one and reboot again. It is so boring. QUESTION: How to automatically switch gpu graphics driver when I enter a game or something that needs more GPU? Multiple file upload in php youtube-dl failed to extract signature It is considered very useful to utilize youtube-dl software for downloading youtubes.  A message is seen and it stopped working, which is following.  ERROR: Signature extraction failed: Traceback (most recent call last):   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 479, in _decrypt_signature     video_id, player_url, s   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 383, in _extract_signature_function     res = self._parse_sig_js(code)   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 454, in _parse_sig_js     u'Initial JS player signature function name')   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 391, in _search_regex     raise RegexNotFoundError(u'Unable to extract %s' % _name) RegexNotFoundError: Unable to extract Initial JS player signature function name; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update. ; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.   What should I do to proceed? Adding Custom Menu "Run Script" Button Causes Duplicate Is there a way to use the Blender Text Editor for adding a custom menu and not get a duplicate every time I click on "Run Script" to test the menu? For example, in the text editor, load the template like so:  Template -> Python -> UI Menu  Then notice every time you press "Run Script" you get another menu in your main menu bar. How can I update my menu without getting a duplicate?  I tried simply commenting out register() but then new updates don't show up. In Hitchcock's Vertigo, there is one part of the film that has never made sense to me and I believe that it was a cheap ploy to mislead the audience until the ultimate reveal (I won't spoil it here).    In this scene Jimmy Stewart watches Kim Novak enter a rooming house and afterwards sees her standing by the window on the 2nd floor.  When he enters the house and talks to the inn-keeper, she tells him that Kim Novaks's character positively never came in and even shows him her room key that is still behind the front desk.  They go up to the room and find it empty.   This scene seems to imply that the Kim Novak character may have had a ghost like quality. But given the reveal at the end she clearly does not and there was no way for her to enter the room without a key and without being seen by the inn-keeper.  If this was done by some other director I probably wouldn't have given this much thought but Hitchcock was a perfectionist (especially for this film) so I never understood the significance of this scene other than to mislead the audience (with a cheap ploy IMO).  Does anyone who is familiar with this film have a different explanation/perspective about this scene in an otherwise brilliant movie. An image alt="" text should contain information about that image in the context of the page, so for instance if you have an article about cats on skateboards and then a photograph of the cat on his skateboard you'd probably give it the alt text of alt="Fluffy pulling some mad tricks on his pimped-out board".          &ndash; Wireframes created with   However, what should happen when that image is a link to a page (such as the Wikipedia cat page)?  I don't think there is any point using the title attribute here because screenreaders just ignore that when an alt attribute exists - the only people who would see the title attribute are mouse users who hover over the image, so that excludes keyboard only users too. It's not really any benefit to accessibility to include a title in this situation (Overall the title attribute is a bit useless really).  So, what should the image ALT text say in this case?   states:     Provide text alternatives for any non-text content so that it can be changed into other forms people need, such as large print, braille, speech, symbols or simpler language.    Therefore giving it the alt text of cat article page on Wikipedia is incorrect because that doesn't describe the image, neither does skateboarding cat image that links to the wikipedia article because the alt text should refer to the image itself, not the link associated with it. I ran dolphin like this:  dolphin . &amp;   I see messages in the console like these:  QPixmap::scaled: Pixmap is a null pixmap   How can I keep the console clean or silent? Novel about a teleportation device and a con artist alien Notation for intervals I have frequently encountered both $\langle a,b \rangle$ and $[a,b]$ as notation for closed . I have mostly encountered $(a,b)$ for open intervals, but I have also seen $]a,b[$. I recall someone calling the notation with $[a,b]$ and $]a,b[$ as French notation.   What are the origins of the two notations?  Is the name French notation correct? Are they used frequently in France? Or were they perhaps prevalent in French mathematical community at some point? (In this  Bourbaki is mentioned in connection with the notation $]a,b[$.)      Since several answerers have already mentioned that they have never seen $\langle a,b \rangle$ to be used for closed intervals, I have tried to look for some occurrences for this. The best I can come up with is the article on , where these notations are called Czech notation and French notation. Using $(a,b)$ and $[a,b]$ is called English notation in that article. (I am from Central Europe, too, so it is perhaps not that surprising that I have seen this notation in lectures.) I also tried to google for  or . Surprisingly, this lead me to a  where this notation is used for open interval. This might seem like a very simple question, but what is the easiest way to turn a normal vertical list into a horizontal one?