I'm a beginner in Python and I'm studying from the book Learning Python 5th edition by Mark Lutz.  In studying scoping and object reference, I've run across one thing that I quite did not understand. I understand that when you assign an object to other object, they're merely sharing a reference to the same address unless you perform top-level copying. However, I noticed that when you 'nest' the object, two objects no longer share the same address.   For example,  &gt;&gt;&gt; L = [4, 5, 6] &gt;&gt;&gt; X = L * 4                   # Like [4, 5, 6] + [4, 5, 6] + ... &gt;&gt;&gt; Y = [L] * 4                 # [L] + [L] + ... = [L, L,...]  &gt;&gt;&gt; X [4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6] &gt;&gt;&gt; Y [[4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]]   &gt;&gt;&gt; L[1] = 0                    # Impacts Y but not X &gt;&gt;&gt; X [4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6] &gt;&gt;&gt; Y [[4, 0, 6], [4, 0, 6], [4, 0, 6], [4, 0, 6]]   This is the part I don't understand. Why does changing L object impact Y but not X?
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?
GPG Error while downloading software: "Clearsigned file isn't valid, got 'NODATA'" In a Poisson model, what is the difference between using time as a covariate or an offset? I recently discovered how to model exposures over time using the log of (e.g.) time as an offset in a Poisson regression.  I understood that the offset corresponds to having time as covariate with coefficient 1.  I'd like to better understand the difference between using time as an offset or as a normal covariate (therefore estimating the coefficient). In which situation should I want to use one method or the other?  UPGRADE: I don't know if it is interesting, but I ran a validation of the two methods using randomly split data repeated 500 times and I noticed that using the offset method leads to a larger test error. Retagging questions in terms of possible answer technologies If $f$ is measurable and $fg$ is in $L^1$ for all $g \in L^q$, must $f \in L^p$? Let $f$ be a measurable function on a measure space $X$ and suppose that $fg \in L^1$ for all $g\in L^q$. Must $f$ be in $L^p$, for $p$ the conjugate of $q$? If we assume that $\|fg\|_1 \leq C\|g\|_q$ for some constant $C$, this follows from the Riesz Representation theorem. But what if we aren't given that such a $C$ exists? How to convert HTML to XHTML? I need to convert HTML documents into valid XML, preferably XHTML. What's the best way to do this? Does anybody know a toolkit/library/sample/...whatever that helps me to get that task done?  To be a bit more clear here, my application has to do the conversion automatically at runtime. I don't look for a tool that helps me to move some pages to XHTML manually. I have a directory with numerous files. Part of the files have the 755 permissions and the other part have 644 permissions. I'd like to convert the files with 755 permissions to 644. I have tried the following line by running it from the directory itself:  find . -perm 755 -exec chmod 644 {}\;   However as a result, the permission changed only for the directory itself and after changing it back I found out that the files permissions remained unchanged. Do I miss something? SPWeb.getFile(Url) exception : value does not fall within the expected range Simple problem with Manipulate and Plot Is $2^\sqrt{2}$ irrational? Is it transcendental? Duplicates of an outdated question If a new question addresses the same issue that another question does, but the answers to the original question is sufficiently outdated, should the new question still be closed as a duplicate? How to find the determinant of this $3 \times 3$ Hankel matrix? Today, at my linear algebra exam, there was this question that I couldn't solve.   Prove that $$\det \begin{bmatrix}  n^{2} &amp; (n+1)^{2} &amp;(n+2)^{2} \\  (n+1)^{2} &amp;(n+2)^{2}  &amp; (n+3)^{2}\\  (n+2)^{2} &amp; (n+3)^{2} &amp; (n+4)^{2} \end{bmatrix} = -8$$   Clearly, calculating the determinant, with the matrix as it is, wasn't the right way. The calculations went on and on. But I couldn't think of any other way to solve it. Is there any way to simplify $A$, so as to calculate the determinant? The iOS-app should provide (at least) the same features as the site and the ability to edit your profile is not so unimportant.  In my opinion, the user should be able to change the every single info-field in his profile (including, but not limited to nickname, description, profile picture) by pressing an "Edit" button which should be located somewhere on his or her profile view. How to split a string in Java Lots of new batteries (for mobile devices, MP3 players, etc) have connectors with 3 pins. I would like to know what is the purpose of this and how should I use these three pins?    They are usually marked as (+) plus, (-) minus, and T. Do photons lose energy due to gravitational redshift? If so, where does the lost energy go? In the gravitational redshift, the frequency of photons radiated from some source is reduced. As the energy of a photon is given by $\hbar\omega$, if the frequency is reduced where is the lost energy? When I was a kid we had a VHS tape of some Disney live action (not animated) sci-fi movie. It may have been a mini-series or a made-for-tv movie, but I'm not sure. I'm also not sure about the year but it would probably have been late 80s or early 90s based on when I would have seen it. I know it was Disney because they had some live action Goofy and Mickey running around the movie's set as an introduction discussing the plot with a host before the movie.  The plot is basically as follows:   A starship is loaded with mostly children and teenagers as a cross-galaxy human settling effort. Accidents (which are not really accidents and later revealed) cause adult crew members to be killed.  They travel to another planet and face all sorts of troubles. It arrives at the new planet after overcoming obstacles.   Other memorable scenes that may help:   Navigating out of earth's asteroid belt made out of space junk. One of the adults was killed via an airlock malfunction. The ship was supposed to be peaceful with no weapons. At one point they bring on board some crazy guy who puts together a rail gun. There's a memorable line like "Do you want no weapons at all or a well aimed rock?"  There's a planet or space station (I can't remember which) that has a fight scene with the evil bad guy. This scene takes place on what looks to be a carnival or fairground. The bad guys are trying to steal the ship the kids are on because it has some kind of really good futuristic space drive.   Hopefully you remember it better than I do! I've tried looking online for it before with no luck. "going to" definition, does it imply intent? I have had a debate with one of my friends about this little game:  "1 rabbit saw 9 elephants while going to the river. Every elephant saw 3 monkeys going to the river. Each monkey had 1 tortoise in each hand. How many animals are going to the river?"  Answers:   4 - if you could rabbit and monkeys (which are described as "going to" the river)  10 - if you are counting tortoises in monkeys' hands 19 - if you assume all   my argument is that the tortoises are not "going to", but are being either "taken to" or "move towards" river. That's what I would say if someone holds me and goes to the river.  my friend's argument is that because they move towards the river, they are "going to" the river. he gave example of me being in the car.  Me: If I don't intend to go there, I'm being "taken to", even if in the car.  Question: does "going to" implies intent of the subject ? The  specifically says not to ask  for career advice but people do it anyway.  Should I consider the Help Center outdated or only loosely enforced?    And what about a career advice site on the network?  There are 70+ sites, and most of them are for relatively narrow interests (which is not a criticism, I enjoy looking through the many sections).  A career section seems like it would be very popular.  Also, a careers section would help keep career questions off the other sites. Finding local maximum and minimum How can I add new autostart programs in Lubuntu? In Lubuntu, there's no 'Add New Program...' button in Desktop Session Settings. Is there an easy way to add new autostart programs in Lubuntu?