Change a global variable through a function: UnboundLocalError
Using global variables in a function
How to replace text between quotation marks with something from another file? I have the following kind of text: $OU = 'or'; $DINHEIRO_CAIXA = 'Cash balance'; $PAGINA = 'Page'; $DE = 'from'; $ENVIAR = 'Send'; $PRINCIPAL = 'Main';  I've already got all the text within the single quotation marks using cat arquivo | grep -oP &quot;'[^']+'&quot; | tr -d &quot;'&quot; This extracted text was then translated to Portuguese, but now I don't know how to replace the original text between single quotation marks with the translated text, I was looking for something like $OU = 'ou'; $DINHEIRO_CAIXA = 'Dinheiro em caixa'; $PAGINA = 'Pagina'; $DE = 'de'; $ENVIAR = 'enviar'; $PRINCIPAL = 'Principal';  I've tried using grep -F to replace the file itself, but it failed miserably because the pattern didn't match since I don't have the quotation marks on the new file, is there a way to do this? Why is "cupboard" pronounced with a silent "p"? According to Google at least, the word "cupboard" originated in late Middle English as denoting a board that held cups. Since then, the word has evolved to mean a kind of cabinet.  My question is, given its origin and spelling, why do we pronounce "cupboard" with a silent "p"? Has the pronunciation simply evolved because "cup-board" is too awkward to say, or is there a deeper pronunciation rule that I'm not aware of? Schedule to open website I'd like to open a website at regular intervals per day, i.e., the browser should open and automatically navigate towards a pre-set URL.  I looked at options like scheduling to open browser, but I can't figure out how to open it with a default URL. (No I do not want to make this my start page)  Any help is appreciated "Basis extension theorem" for local smooth vector fields I believe that the set of all $\mathbb{R\to R}$ continuous functions is $\mathfrak c$, the . However, I read in the book &quot;Metric spaces&quot; by Ó Searcóid that set of all $[0, 1]\to\mathbb{R}$ continuous functions is greater than $\mathfrak c$:  &quot;It is demonstrated in many textbooks that $\mathbb{Q}$ is countable, that $\mathbb{R}$ is uncountable, that every non-degenerate interval is uncountable, that the collection of continuous functions deﬁned on  $[0,1]$ is of a greater cardinality than $\mathbb{R}$, and that there are sets of greater and greater cardinality.&quot;  I understand that (via composition with the continuous function $\tan$ or $\arctan$) these sets of continuous functions have the same cardinality. Therefore, which claim is correct, and how do I prove this? how to restore windows 7 to a know working state every time it boots A couple of days ago my mother asked me to set up a computer at her house, she wants to use it to basic web browsing, video chat and nothing more.  The problem is, neither my mother nor my sister know anything about using or maintaining a computer.  What I want is to have a working base install of windows 7 and just discard everything installed, downloaded, ... when it reboots. That way I can set up a partition just for saving files and whatever they do the computer will always return to a working state at start up.  can that be done?  PS: Sadly linux is not an option since my sister wants to be able to play some games with my steam account and not all of them run with wine. Can there be multiple paths for which Fermat's least time principle can be obeyed? Can there be more than one path for which Fermat's least time principle is obeyed? What is the optimal path between $2$ fixed points around an invisible obstructing wall? Every day you walk from point A to point B, which are $3$ miles apart. There is a $50$% chance each walk that there is an invisible wall somewhere strictly between the two points (never at A or B). The wall extends $1$ mile in each direction perpendicular to the line segment (direct path) between A and B, and its position can be at any random location between the two points. That is, it can be any distance between A and B such as $0.1$ miles away from A, $1.5$ miles away, $2.9$ miles away.... You don't know if the wall is present or where it is until you walk into it.  You must walk around the wall if present as there is no other way to circumvent it.  Assume the wall is negligible thickness (like a force field), all ground is perfectly flat, and the y coordinates at both A and B are $0$ (although I don't think the optimal path will change much if they weren't).  What strategy minimizes the average expected walk distance between A and B?  How do we know for certain this strategy yields the shortest average walking distance?  To get the $100$ bounty points, I would like a convincing argument from you as to why you feel your solution is optimal and cannot be beaten.  For those of you using computer simulation, anything reasonably close to optimal is a candidate for the bounty.   Can anyone beat the optimal solutions submitted so far?  There are still a few days to try.  Even a slight beat (if not due to roundoff error or some other error) would help prove previous solutions are non-optimal.  You can just use the table of $31$ points (x-y coordinates) and compute that path length and then if you can find better then I will accept that answer.  I think by Sunday night I may have to award the bounty otherwise it may get auto-awarded. Subscript labels in QGIS legends Is it possible to include subscript and superscript text in the title of a legend item in QGIS ?  I have tried using &lt;sub&gt;some text&lt;/sub&gt; but this just appears in the title with no change to the contents.  I am looking to have layer titles such as   Annual NO2 concentration (μg/m3)  The superscript is not a big issue, as I can use the character map to get a 3, but I don't know how to get the subscript. File upload to Heroku not working bcmwl-kernel-source broken on kernel: 5.8.0-34-generic Writing in bash while it is working When you are performing time consuming operations in bash like installing new software, is it possible to write text that will appear at the prompt when the operation has finished.  E.g   Imagine running:  apt-get install eclipse-platform   Then it will use quite a while to finish while you see the installation log, meanwhile I want to create new folders (workspaces) which Eclipse later will use.  Is this possible without opening a new terminal (or tab)? What's the difference between using a 50mm f/1.8G and a 50mm f/1.8D with a Nikon D80? Recently, Nikon announced their , as revamp of the old 50mm f/1.8D. :     The main difference between this new   "nifty fifty" and the almost   decade-old ƒ1.8D is that it has an   autofocus motor inside. This means you   can use it with any current or recent   Nikon SLR. The older lens lacks this   motor and is instead driven by one in   the camera, which cheaper bodies don't   have.   I currently use a Nikon D80 (and I don't plan on changing that any time soon), and I've been considering getting such a lens. Is there any difference between the D and the G lenses when used on a D80? I believe that the D one works just as well, since D80's have internal autofocus motors - is that right?  Besides the autofocus motor aspect, is there any other big difference between them? Since the D is priced at around $120 and the G at $220, should I just get the D? How many complements are in "I ask you to clean the room"? How many complements are needed in the below sentence?     "I ask you to clean the room."   This sentence above has one complement or two complements? Should I test private methods or only public ones? I have an URL structure like the following:     sitename.com/cellphone/nokia/galaxy-5678-nokia-cellphone-from-abc/   For more example:     sitename.com/cellphone/motorolla/new-motorolla-gta800-cellphone-from-zxy/   The directory structure is like the cellphone is the main directory of the module and the words like Motorolla and Nokia are subdirectories which are categories and then comes the title of the cellphone.  Here the word cellphone and Nokia in the first link and cellphone and Motorolla in the second link are repeated.  Is it any kind of keyword stuffing? will it be penalized by Google? The limit of a convergent Gaussian random variable sequence is still a Gaussian random variable I'm trying to prove this conclusion but have some problems with one of the steps.  Assume $X_1,\ldots,X_n,\ldots$ is a sequence of Gaussian random variables, converging almost surely to $X$, prove that $X$ is Gaussian.  We use characteristics function here. Since $|\phi_{X_n}(t)|\leq 1$, by dominated convergent theorem, we have for any $t$  $$ \lim_{n\rightarrow\infty}e^{it\mu_n-t^2\sigma_n^2/2}=\lim_{n\rightarrow \infty}\phi_{X_n}(t) = \lim_{n\rightarrow \infty}\mathbb{E}\left[e^{itX_n}\right] = \mathbb{E}\left[e^{itX}\right] = \phi_X(t) $$  this is the step that I cannot figure out: $e^{it\mu_n-t^2\sigma_n^2/2}$ converges for any $t$ if and only if $\mu_n$ and $\sigma_n$ converges.   Let $\mu=\lim_n \mu_n$, and $\sigma=\lim_n\sigma_n$, then $\phi_X(t)=e^{it\mu-t^2\sigma^2/2}$, which proves that $X$ is a Gaussian random variable.  Why can we get that $\mu_n$ and $\sigma_n$ converge? This looks intuitive for me, but I cannot make a rigorous prove. monitor files (à la tail -f) in an entire directory (even new ones) I normally  watch many logs in a directory doing tail -f directory/*. The problem is that a new log is created after that, it will not show in the screen (because * was expanded already).  Is there a way to monitor every file in a directory, even those that are created after the process has started? DOS of Van Hove singularity in 2D square lattice tight binding model For the simplest example, 2D square lattice tight binding model gives the energy band as $$\varepsilon_k=-2t(\cos k_x+\cos k_y) \, .$$ We know that $\mathbf{k}=(0,\pi)$ and related momentum points are saddle points which give $|\nabla_k \varepsilon_k|=0$ and thus some kind of singularity in density of state (DOS) since $$\rho(\varepsilon)\propto \int_{\varepsilon=\text{const}} \frac{d S}{|\nabla_k \varepsilon_k|} \, .$$ How can I get the $\ln$ divergence for DOS near $\varepsilon=0$? Should I only care about those singularity points and omit the integral from normal parts and do Taylor expansion near those saddle points?   Moreover, why are points like $(\pi/2,-\pi/2)$ or $(2\pi/3,-\pi/3)$ not called Van Hove points when those points are also lie in the $\varepsilon=0$ line and give $|\nabla_k \varepsilon_k|=0$? I'm trying to debug a Python script by placing a print("foo=" + foo) statement in my code.  But where does the output appear?     It doesn't appear on the Python Console, and it doesn't appear on the area that appears when you drag the lower edge of the infobar downwards (what is the name for this area? My script errors show up in red here.)