I need an insight into understanding the below code. The first print gives me output: 'a' whereas on changing the value of y[0][0] to "p" it changes the value of y[0][0], y[1][0], y[2][0] and y[3][0] as well. I was expecting an output like [['p', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c']] but instead got [['p', 'b', 'c'], ['p', 'b', 'c'], ['p', 'b', 'c'], ['p', 'b', 'c']]  x=["a","b","c"] y = [x] * 4 # first print print(y[0][0])  y[0][0] = "p" # second print print(y)
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?
Pointwise Convergence and Convergence in the mean of Riemann-integrable functions Let $(f_n)_{n\in\mathbb{N}}$ be a sequence of Riemann-integrable functions on $[a, b]$.   Assume that $(f_n)_{n\in\mathbb{N}}$ converges pointwise to $f$ on $[a, b]$ and converges in the mean to $g$ on $[a, b]$, where $f$ and $g$ are both continuous. Show that $f = g$.   ($(f_n)_{n\in\mathbb{N}}$ converges in the mean to g on $[a , b]$ means that $\lim_{n\to\infty} d(f_n, g) = 0$, where $d$ is the $L_2$ metric.)  I am studying real analysis now and want to prove this statement. But I don't know how to use condition "$(f_n)_{n\in\mathbb{N}}$ converges in the mean to g on $[a , b]$." How can I prove this? I want to shrink my second (LVM) partition, in order to create a new partition in the newly freed space. I am using the Live CD to do so, because I know I can't resize/move this partition while it is in use. When I opened GParted in the Live CD, I realized that I could not resize the partition, because when I right-click it, the option "resize/move" is disabled.  I tried to unmount it, to "lazy" unmount it (umount -l /dev/sda2) but it didn't work.  A screenshot from GParted: I have continuous problems of network dropping connections on wifi with ubuntu 16.04, I have an ASUS R510J, this is my network card:  ##### lspci #############################  03:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter [10ec:8821]         Subsystem: AzureWave RTL8821AE 802.11ac PCIe Wireless Network Adapter [1a3b:2161]         Kernel driver in use: rtl8821ae  04:00.1 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 12)         Subsystem: ASUSTeK Computer Inc. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [1043:200f]         Kernel driver in use: r8169   sudo service network-manager restart doesnt's help, as I never regain internet connection after it drops, and I have to restart the PC. On Ethernet cable I have no problem.  What do you think is the issue? drivers?  thank you There are many (duplicate) questions about the acceptance, popularity and history of singular they (and their, them and themself) around here, it even got a tag of its own. If I didn’t miss anything, however, the proper verb form hasn’t been questioned yet.  As we all know, English third person singular pronouns (it, she, he and one, +body), names (Alice, Bob, …) and nouns (student, teacher, …) demand the +(e)s suffix be added to the finite verb form in simple present, where some auxiliary verbs have a “special” form (is &lt; *bes / *ares and has &lt; *haves). All other subjects don’t, including plural third person pronoun they.  When the plural you replaced thou (with thee, thy / thine), the other marked verb form that had remained in English – i.e. suffix +(e)st or +t – vanished, too. The first and second persons only ever appear as pronouns (I, we; you), not names or nouns, so there was no strong inclination to keep the verbal inflection.  The second person precedent would suggest that singular they be used with uninflected verb forms which is how it’s usually encountered in the wild. Assuming that they someday replaces he and she (and maybe it) it would lead to disagreement with the words the pronoun stands in for:        Alice         goes to her   place  by herself.   Bob           goes to his   place  by himself.   Alice and Bob go   to their place  by themselves. – (common)   Alice and Bob go   to their places by themselves. – (separate)                  She  goes to her   place  by herself.   He   goes to his   place  by himself.   They go   to their place  by themselves.   They go   to their places by themselves.                  They ?goes to their place  by themself.   ditto   They  go   to their place  by themselves.   They  go   to their places by themselves.                  They ?go to their place  by ?themselves.   ditto   They  go to their place  by  themselves.   They  go to their places by  themselves.      So why doesn’t singular they afford s on present-tense verbs like all other third person singular subjects do?   I learned about singular they only long after I had been taught English as a second language in school. That’s why it’s still a conscious decision to use it and hence I could easily adapt to use s forms with it, but would that sound and look funny / strange / wrong to native speakers? Fantasy book with shape shifting dragon warriors Set in a fantasy world with shape shifting Dragon kings and their warriors. They terrorize the humans, and kill those with magic.   The protagonist is the great-grandson of a powerful warlock. He finds out that he has magic, and fights with it to save his new friends, the Griffin, Blackhorse (I think that's his name), some creepy necromancer who is immortal, and Gwen (fellow sorceress), along with the kingdom that the Griffin rules in.   They fight the protagonist's father, the leader of the Dragon kings, the king's Duke, and the creepy sorcerer, who has a curse (when he dies, he changes side from good to bad, or bad to good). I have no clue what this is called, but I want to find out, since I'm out of things to read. Why did the slaver in Astapor think Daenerys wouldn't do exactly what she did? Spoilers! (do I have to even say that here?)  I recently rewatched the episode of Game of Thrones where Daenerys is in Astapor. She makes the deal with the master slaver guy, where she trades him one of her dragons for 8,000 of his very tough slaves. I immediately thought this was stupid for two reasons:   Why would he think the dragon would immediately obey him rather than her? Maybe he doesn't quite believe the 'Mother of Dragons' lore, but it's still basically a pet at the very least. This one isn't as bad though, as... Why would he possibly think she wouldn't betray him and use her freshly bought slaves to take back her dragon? He just traded her literally all his slaves and he has not been kind to her so far. He has motivation to not go back on the deal -- he's running a business, basically... but she has no reason not to.   I guess you could argue that he was blinded by greed, but I think that would be poor writing -- he's in a vicious trade, I can't imagine he would've survived long thinking so naively.  Does anyone have a good explanation? Find the number of solutions of $a_0+a_1+a_2=17$ if $2\le a_0\le 5$,   $3\le a_1\le 6$, $4\le a_2\le 7$.   This is an exmaple given by my professor, and his solution is:       The number of solutions to this equation satisfying the given   constraints is equal to the coefficient of $x^{21}$ in the expression   $$\left(\sum_{n=2}^5x^n\right)\left(\sum_{n=3}^6x^n\right)\left(\sum_{n=4}^7x^n\right)=x^9\left(\sum_{n=0}^3x^n\right)\left(\sum_{n=0}^3x^n\right)\left(\sum_{n=0}^3x^n\right).$$   This must be 3, since the coefficient of $x^8$ in $(1+x+x^2+x^3)^3$ is   3.   I understand actually nothing here. The expression of summation just pops up, and then comes the answer. What I only know that the idea of generating function is used here. Can someone help explain how the steps in the solution come? $A$ is an $n\times n$ matrix of complex numbers. Prove that if $\lambda$ is an eigenvalue of $A^2,$ then $\sqrt{\lambda}$ or $-\sqrt{\lambda}$ is an eigenvalue of $A.$    If $\lambda$ is an eigenvalue of $A^2,$ we have $\lambda\alpha=A^2\alpha$ for some $\alpha.$ Then how can we find a $\beta$ s.t. $\sqrt{\lambda}\beta=A\beta?$ Beamer, page/frame numbers, buttons and Appendix slides How can I assign the output of a command to a shell variable? I want to assign the result of an expression (i.e., the output from a command) to a variable and then manipulate it – for example, concatenate it with a string, then echo it.  Here's what I've got: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 &quot;Screen Shot&quot;; echo &quot;Most recent screenshot is: &quot;$thefile;  But that outputs: Screen Shot 2011-07-03 at 1.55.43 PM.png Most recent screenshot is:   So, it looks like that isn't getting assigned to $thefile, and is being printed as it's executed. What am I missing? LaTeX minted Error I receive the following errors:  ! Package minted Error: You must invoke LaTeX with the -shell-escape flag. ! Package minted Error: You must have `pygmentize' installed to use this packag   in TexMaker Settings i wrote:     LaTeX : "/usr/texbin/latex" -interaction=nonstopmode %.tex -shell-escape      PdfLaTex: "/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode   %.tex -shell-escape   But the error still doesn't vanish ... Is it possible to create an iron door which responds to levers on both sides When should one use final for method parameters and local variables? I've found a couple of references () that suggest using final as much as possible and I'm wondering how important that is. This is mainly in the the context of method parameters and local variables, not final methods or classes. For constants, it makes obvious sense.  On one hand, the compiler can make some optimizations and it makes the programmer's intent clearer. On the other hand, it adds verbosity and the optimizations may be trivial.  Is it something I should make an effort to remember? If every compact set is closed, then is the space Hausdorff? Selecting text in profile activity comments causes unexpected clipping If $R$ is an integral domain and a subring $S$ has identity $1_S$, how would you show that $1_S=1_R$ (here $1_R$ is the identity of the ring $R$)? I am unsure about what an integral domain really is and how the subring comes into play here. Group files in some folders I have some files with different extensions such as *.pdf, *.mp3, *.jpg and a few others. All of them are stored in a parent directory.  How can I get a list of all extensions, create some folders based on these  extensions and then move all files into their relevant folders? Apex PMD: Problem: Validate CRUD permission before SOQL/DML operation Background   I am using the Apex PMD plugin for VS Code and it's giving me this problem:     Validate CRUD permission before SOQL/DML operation   For this line of code:  insert contentVersion;   Which is part of this method:  private void attachReport(Id recordId) {      ContentVersion contentVersion = new ContentVersion(         versionData = Blob.valueOf(buffer.toStr()),         title = 'Import Report',         pathOnClient =  StringUtils.format('/Import-Report-{0}.txt', DateTime.now().getTime()),         FirstPublishLocationId = recordId);      insert contentVersion; }   Questions    Why am I getting the problem? What should I do to not get the problem?     Reference As I understand this, firewalls (assuming default settings) deny all incoming traffic that has no prior corresponding outgoing traffic.  Based on  and , reverse SSH tunneling can be used to get around pesky firewall restrictions.  I would like to execute shell commands on a remote machine. The remote machine has its own firewall and is behind an additional firewall (router). It has an IP address like 192.168.1.126 (or something similar). I am not behind a firewall and I know the remote machine's IP address as seen from the Internet (not the 192.168.1.126 address). Additionally, I can ask someone to execute ssh (something) as root on the remote machine first.  Could anyone explain me, step by step, how reverse SSH tunneling works to get around the firewalls (local and remote machines' firewalls and the additional firewall between them)?  What is the role of the switches (-R, -f, -L, -N)? What does if __name__ == "__main__": do? Given the following code, what does the if __name__ == "__main__": do?  # Threading example import time, thread  def myfunction(string, sleeptime, lock, *args):     while True:         lock.acquire()         time.sleep(sleeptime)         lock.release()         time.sleep(sleeptime)  if __name__ == "__main__":     lock = thread.allocate_lock()     thread.start_new_thread(myfunction, ("Thread #: 1", 2, lock))     thread.start_new_thread(myfunction, ("Thread #: 2", 2, lock))