I currently have a python program which imports a function from a file, but this function uses a variable which is stored in the file the functon is called from.  The code for the main function:  from second_file import second  while True:      print second(param)   The code for the second function:   counter = 0  def second(param):      counter +=1      return param + counter   When running the programm i get the following error:  local variable 'counter' referenced before assignment   So the question is, how can i get the "second" function to use this variable.
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?
What regulations should a European driver know when driving in the US? There are the obvious ones. The US has the keep-your-lane system, where as in Europe you are expected to keep to the right (left for UK) as long as possible.  On my latest travel to the US, I was confronted with the possibility to go through a red light if you turn right, unless it is explicitly not allowed.  What should a european driver know when driving in the US? What are the do's and don'ts compared to driving in Europe. Network reputation graph becomes nervous when clicking quickly, backs away slowly WinForms Global Exception Handling? What are the best SEO practices when changing domain names? I'm using the Yoast SEO plugin on a WordPress site on a new, more memorable domain to replace an old static HTML site with no SEO. I've followed , set up 301 redirects from the old domain to the new one, and filed a change of address in the Google Search Console. However, after a few days, the old site still shows in search results, and is ranked higher than the new one if you google our company name.   And, if I try to set the preferred domain in the Google Search Console Site Settings for the new site, I see this in place of the options to prefer www/non-www/http/https:     Not all options are available because of a Change of Address request   related to this site.   I've read of some cases where this condition has lasted for .  Is there anything more I can do to fix this? Have I done something wrong, or do I just need to wait, and for how long? How do I set a user environment variable? (permanently, not session) I am writing a small KOMA-Script scrartcl document with multiple sections. In the table of contents, LaTeX fills the current line with dots between the end of the section name and the page number. Is there any way to customize this behavior? I would like to reduce the space between the single dots (i.e. use more dots in the same space). I had studied group theory a year ago, but still could not understand the proof involving The Correspondence theorem.  let $G$ be a group and let $N⊴G$, where  $N⊴G$ indicates that $N$ is a normal subgroup of $G$. Then there is a bijection from the set of subgroups $A$ of $G$ that contain $N$ onto the set of subgroups $\overline A $=$A/N$ of $G/N.$  Can anyone explain the steps to me in:  $(1.)$ a very easy-going manner so that I understand importance of each step. $(2.)$I don't require the proof but only how the step follow each other .  I'll be thankful if there is anyone kind enough to do this.... Compiling with g++ using multiple cores Apostrophes for possession: nouns My best friend of the moment - 'Essential Grammar in Use' for elementary students by Raymond Murphy - says that 'we normally use -'s for people.'     I stayed at my sister's house. (not the house of my sister).   Then, bellow in the same unit (64) says that 'we use of... for things, places, etc.'     Look at the roof of that building. (not that building's roof)   After that I thought:  Finally!!! I understand the rules for apostrophes!!!  But soon I lost all that naif excitement when I saw other written examples on the internet that were not following those 'rules'.     I've learnt that we can apply apostrophes to ...     one year's pay   and, finally, amazingly enough ... to , which means ANY kind of nouns (I deduce uncountable nouns are also part of the possibilities). This demolishes what is said in the grammar. So, it seems that eventually:     That building's roof -> is valid   So, now I need your help.    1) Can you tell me the rules concerning the apostrophe to show possession in respect to its usage with nouns? Can we really apply to all kind of nouns? e.g. teeth's, vehicle's, Paula's, forest's, manager's, Ireland's, etc     Scotland's worst drivers   Metadata improves information's accessibility       2) Is there a sense that justifies what is written in the grammar: 'we normally use -'s for people'? or it does not make sense at all? Why does a helium filled balloon move forward in a car when the car is accelerating? Possible Duplicate:          I installed the IE10 beta on Windows 7. It has an annoying autocorrect feature like the one in MS Word that messes up everything I write. How do I disable it? What's the added value of SD line over regression line when examining association between 2 variables? I'm trying to incorporate different practices to use when exploring a new data set. Especially, how to examine the association between two variables.  Steps for example (not necessarily by order):   plot a y-by-x scatter plot of the raw data to see the relationship visually. compute summary statistics for each variable (mean and sd) compute correlation coefficient r draw the OLS regression line, compute its slope and intercept etc....   I've come across the "SD line" in Freedman's Statistics book, which is defined as:     "the line that goes through the point of averages and climbs at the rate of one vertical SD for each horizontal SD" Freedman, D., Pisani, R., &amp; Purves, R. (2007). Statistics (4th edn).   Since this book ("Statistics") is a canonical textbook, I consider its choice to discuss the SD line as an indication for the line's importance. However, a simple google search for the term "SD line" doesn't yield as many independent results. Most of them come directly from Freedman's book. This tells me it's not a central concept in bivariate analyses in general.  When comparing the SD with the OLS regression line, it seems like the regression line is more informative (than the SD line) for predicting y from x. Therefore, I'm wondering if bothering to plot the SD line has any benefit or added value that I would not already have when plotting the regression line.  Example using mtcars dataset, focusing on association between weight and mpg  data(mtcars)  ## calculate means mean_wt &lt;- mean(mtcars$wt) mean_mpg &lt;- mean(mtcars$mpg)  ## calculate standard deviations sd_wt &lt;- sd(mtcars$wt) sd_mpg &lt;- sd(mtcars$mpg)  ## scatter plot plot(x = mtcars$wt, y = mtcars$mpg)  ## add the "point of averages" points(mean_wt, mean_mpg, col = "red", cex = 1.5, pch = 16)  ## calculate the slope of the sd line slope &lt;- -1*sd_mpg/sd_wt  ## plot the sd line curve(expr = x*slope + (mean_mpg - slope*mean_wt), add = TRUE, col = 'blue', lwd = 2, type = "l", lty = 2)  ## plot the regression line model &lt;- lm(mpg ~ wt, data = mtcars) abline(model, col = "orange", lwd = 2)  ## legend legend("topright",        legend = c("Regression line", "SD line"),        col = c("orange", "blue"),        lty = c(1, 2),        lwd = c(2, 2))     Thus, my question: how can the SD line increase one's understanding about the relationship between two variables, in a way that's either adding or complementing on what the regression line already tells? "Access is denied" JavaScript error when trying to access the document object of a programmatically-created  (IE-only) Cannot find Background Images feature to add in a photo in Blender 2.8  Where is it? Sum with binomial coefficients: $\sum_{k=0}^{n}{2n\choose 2k}$ I'm repeating material for test and I came across the example that I can not do. How to calculate this sum: $\displaystyle\sum_{k=0}^{n}{2n\choose 2k}$? What does the term saturating nonlinearities mean? I was reading the paper  and in section 3 were they explain the architecture of their Convolutional Neural Network they explain how they preferred using:     non-saturating nonlinearity $f(x) = max(0, x). $   because it was faster to train. In that paper they seem to refer to saturating nonlinearities as the more traditional functions used in CNNs, the sigmoid and the hyperbolic tangent functions (i.e. $f(x) = tanh(x)$ and $f(x) = \frac{1}{1 + e^{-x}} = (1 + e^{-x})^{-1}$ as saturating).   Why do they refer to these functions as "saturating" or "non-saturating"? In what sense are these function "saturating" or "non-saturating"? What do those terms mean in the context of convolutional neural networks? Are they used in other areas of machine learning (and statistics)? Is there an open dense set $S \subset [0,1]$ such that $m(S)<1$? $m$ is the Lebesgue measure. I was thinking that: $\Bbb Q$ is dense and $m(\Bbb Q)=0&lt;1$ but it fails to be open, but maybe I could construct an open set from this fact, or also using that $(0,1)$ is a dense and open subset but $m(0,1)=1$.   Any hints or ideas will be very appreciated. Thanks. How to make UV loft like 3ds Max in Blender using curves? I am try to make a car Body using the technique like UV loft in 3ds Max.  How to apply this technique in  Blender using curves or closer to this technique? I have seen this technique in a Blender tutorial, but I forgot about it. Try to do something vs. Try doing something Is there any differences between      Try to do   And     Try doing   Thank you in advence. What would have happened if Voldemort had won Priori Incantatem before Nagini had been decapitated? As wielder of an elder wand that belonged to Harry, during Voldemort’s Last Stand, there are two instances of Priori Incantatem occurring, back to back.  Basically, the current order of events makes total sense. Since Nagini was the last horcrux, when the body died, the fragment of Voldemort’s soul locked in it was released. This disrupted the first instance of Priori Incantatem, and Voldemort was now significantly weaker than Harry – so Harry won. Naturally, the Elder Wand’s killing spell was reflected back on Voldemort because of Priori Incantatem outcome.   But, if Voldemort was just told by Harry that the Elder Wand wouldn’t work against Harry because it belonged to Harry, and was a wand that would win any duel for its master, why would Voldemort willingly try and continue to use it? This is doubly so, since after he had cast the killing spell on Harry once it had only torn Voldemort’s soul from Harry’s body – wouldn’t that even imply that the Elder Wand would realistically refuse almost any attempted direct harm against its owner?  Also, wouldn’t a first refusal of the Elder Wand to kill it’s own master also imply an additional refusal even if Voldemort had won either of the Priori Incantatem matches (in which case, the worst that could happen in this line of thinking is, Voldemort has Harry’s wand since Harry’s spell is Expelliarmus)?