player_health = 10  def add(num):   return num + player_health  def monster_room():   print(player_health) # Error on this line   player_health -= 1 # Doesn't crash without this line, even though the error is thrown on the previous line.   print(add(6)) # works monster_room() # doesn't work   I get an error if I try to modify player_health:  UnboundLocalError: local variable 'player_health' referenced before assignment on line 10 in main.py  How the variable is possibly not assigned when I can use it in the add function just fine? Does it not recognize that it's a class-level variable because I'm attempting to modify it inside the function? Does Python have to pass every class-level variable you want to use to the functions so it can do everything at the local scope?
The following code works as expected in both Python 2.5 and 3.0:  a, b, c = (1, 2, 3)  print(a, b, c)  def test():     print(a)     print(b)     print(c)    # (A)     #c+=1       # (B) test()   However, when I uncomment line (B), I get an UnboundLocalError: 'c' not assigned at line (A). The values of a and b are printed correctly. This has me completely baffled for two reasons:   Why is there a runtime error thrown at line (A) because of a later statement on line (B)? Why are variables a and b printed as expected, while c raises an error?   The only explanation I can come up with is that a local variable c is created by the assignment c+=1, which takes precedent over the "global" variable c even before the local variable is created. Of course, it doesn't make sense for a variable to "steal" scope before it exists.  Could someone please explain this behavior?
Macrons appear really wide on all characters, but especially so on the i. Is it possible to make them less wide?  \documentclass{article} \begin{document} Tac\=e, M\=arc\=o, \=unus, f\=\i li\=\i? \end{document} Using Mosfet with seperate Logic Converter and Arduino Hide a Subdomain from Google/Search Engine SEO Result? Showing a number $n$ is prime if $(n-2)! \equiv 1 \pmod n$ how to get rid of arm64 in apt W: Invalid 'Date' entry in Release file /var/lib/apt/lists/_var_cuda-repo-8-0-local_Release N: Skipping acquire of configured file 'non-free/binary-arm64/Packages' as repository 'http://repository.spotify.com stable InRelease' doesn't support architecture 'arm64' E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/main/binary-arm64/Packages  404  Not Found [IP: 91.189.88.161 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/binary-arm64/Packages  404  Not Found [IP: 91.189.88.161 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-arm64/Packages  404  Not Found [IP: 91.189.88.161 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/main/binary-arm64/Packages  404  Not Found [IP: 91.189.88.161 80] E: Some index files failed to download. They have been ignored, or old ones used instead.   After I installed Jetpack for Jetson tx1, my ubuntu constantly tries to fetch arm updates. Is there a way to disable this?  EDIT:   $dpkg --print-architecture amd64  $dpkg --print-foreign-architectures i386 arm64   I see that arm64 is included in foreign architectures. How do I remove it? How to show this function's discontinuity?  $ f(n) = \left\{     \begin{array}{l l}      \frac{xy}{x^2+y^2} &amp; \quad , \quad(x,y)\neq(0,0)\\      0 &amp; \quad , \quad(x,y)=(0,0)    \end{array} \right.$ Typesetting 144...4 with "n times" under the 4's is easy, but what about \sqrt{144...4}? Inspired by  on the math StackExchange, suppose you want to typeset the square root of the number 144...4, that is, 1 followed by n 4's. If you write $\sqrt{1\underbrace{44\ldots4}_{n\ \text{times}}}$, as in the current version of the question, you get a huge radical sign that reaches down to match the "n times" text below the number. Is there an elegant way to typeset this so that the radical sign looks like it would with $\sqrt{144\ldots4}$, but also keeping the underset text in the right place? When overriding equals in Java, why does it not work to use a parameter other than Object? I ran into an interesting behavior recently.  It seems that if I override .equals() to take a parameter other than Object, it doesn't get called.  Can anyone explain to me why this is happening?  It seems to violate my understanding of polymorphism in OOP, but maybe I'm missing something.  Here's much simpler code that shows what I'm seeing:  public class MyClass {   private int x;   public MyClass(int n) { x = n; }   public boolean equals(Object o) { return false; }   public boolean equals(MyClass mc) { return x == mc.x; }   public static void main(String[] args) {     List&lt;MyClass&gt; list = new ArrayList&lt;MyClass&gt;();     list.add(new MyClass(3));     System.out.println("Contains 3? " + list.contains(new MyClass(3)));   } }   When this is run, it prints "Contains 3? false".  It looks like the equals(Object) function is called, even though there is another that would work.  By contrast, if I write equals like this the code works as expected:  public boolean equals(Object o) {   if(!(o instanceof MyClass))     return false;   MyClass mc = (MyClass)o;   return x == mc.x; }   Why isn't it figuring out which version of the function to call based on the type of the parameter? Using Vim I often want to replace a block of code with a block that I just yanked.  But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with large blocks of code this gets messy trying to keep the inserted block and the block to delete separate.  So what is the slickest and quickest way to replace text in Vim?   is there a way to delete text without putting it into the register? is there a way to say e.g. "replace next word" or "replace up to next paragraph" or is the best way to somehow use the multi-register feature? Is it possible to append to innerHTML without destroying descendants' event listeners? In the following example code, I attach an onclick event handler to the span containing the text "foo". The handler is an anonymous function that pops up an alert().  However, if I assign to the parent node's innerHTML, this onclick event handler gets destroyed - clicking "foo" fails to pop up the alert box.  Is this fixable?  &lt;html&gt;  &lt;head&gt;  &lt;script type="text/javascript"&gt;    function start () {     myspan = document.getElementById("myspan");     myspan.onclick = function() { alert ("hi"); };      mydiv = document.getElementById("mydiv");     mydiv.innerHTML += "bar";   }   &lt;/script&gt;  &lt;/head&gt;   &lt;body onload="start()"&gt;    &lt;div id="mydiv" style="border: solid red 2px"&gt;      &lt;span id="myspan"&gt;foo&lt;/span&gt;    &lt;/div&gt;  &lt;/body&gt;  &lt;/html&gt; LaTeX figures side by side I want to place 2 images side by side in LaTeX. I have 2 .png files and I don't understand how to do it in LaTeX. I have tried many ways but could not get a good result. Can "Wow!" be a sentence? The question is clear. Can "Wow!" be a sentence?  Imagine a hypothetical context where I'd utter something like this:     Wow! What an amazing idea! I should think about a way to push this fix.   We see "wow" in casual speech often. It bears punctuation marks (typically an exclamation mark, denoting the rising intonation) and a capital letter &mdash; just like all "regular" sentences.  On the other hand, neither Wow! nor What an amazing idea! contain any verbs. These certainly don't have any parts of speech in the other sentence, so what are they? Are they sentences or clauses? In other words, can "Wow!" be a sentence despite its lack of [any implied] verbs, and subsequently lack of any distinguishable predicates?  Please back up your answers with references. The classical book on commutative algebra Introduction to Commutative Algebra, by Atiyah and Macdonald, has the following as exercise I.11.       A ring is Boolean if $x^2=x$ for any $x$ of $A$. In a Boolean ring $A$, show that     i) $2x=0$ for all $x\in A$;    ii) Every prime ideal of $A$ is maximal, and its residue field consists of two elements;   iii) Every finitely generated ideal of $A$ is principal.     I can but solve the first two of them; for the last one, I cannot even perceive the situation here, for it will not, generally speaking, be a Dedekind domain, whereof my knowledge is somewhat more. I have hitherto tried to find one element for each ideal of two generators which can stand the stead of them, and then proceed by induction. But even the first step fails to produce any result. Thanks for any hints and inspirations in advance. Dealing with a whole bunch of two-line config files, I'd like a way to exclude any files that have a different number of lines.  So, something like:  mv * destdir only if file contains exactly two lines   Or:  wc -l * | grep '^ *2' | xargs mv {} destdir   Except that neither of those is actual working code.  While writing this I realized I do have a way to do this, which is ugly as heck, and I've included it below as an answer.  Is there an easy/clean way to do this? How to order the Ubuntu Phone? Yes, of course, I want that Ubuntu Phone.   Where is the order now button? Set the default permission when creating a file Density of Solid States of Compounds One of the wonderful properties of water (as my high school biology teacher would say) is that in its solid form, it is lighter than its liquid form. This means that when temperatures drop below 0 degrees Celsius, the top layer of water on, say, a lake freezes first. This works out pretty well for any fish or other aquatic creatures living underneath, because the lower layers of water will not freeze.  I know that this is an exception to the general rule of solid and liquid states: A given substance, when transformed into its solid state, will generally sink in a container of its liquid state. My question is this: What other substances are exceptions to this rule (if any?). What features do they share with water that are responsible for this? How to use different domains for multilingual sites and keep users logged in? Two logos in beamer after certain frame The reference to entity "foo" must end with the ';' delimiter