I am wondering why a method of a class doesn't look into its enclosing scope, if a name is not defined.  def test_scope_function():     var = 5     def print_var():         print(var) # finds var from __test_scope_function__     print_var()   globalvar = 5 class TestScopeGlobal:     var = globalvar # finds globalvar from __main__      @staticmethod     def print_var():         print(TestScopeGlobal.var)   class TestScopeClass():     var = 5      @staticmethod     def print_var():         print(var) # Not finding var, raises NameError  test_scope_function() TestScopeGlobal.print_var() TestScopeClass.print_var()   I would expect TestScopeClass.print_var() to print 5 since it can read classvar in the TestScopeClass body.  Why this behavior? And what should i read in the  to get to know about it.
What exactly are the Python scoping rules?  If I have some code:  code1 class Foo:    code2    def spam.....       code3       for code4..:        code5        x()   Where is x found?  Some possible choices include the list below:   In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop   Also there is the context during execution, when the function spam is passed somewhere else. And maybe  pass a bit differently?  There must be a simple reference or algorithm somewhere.  It's a confusing world for intermediate Python programmers.
How do I remove Windows 7 from my dual boot system with Ubuntu? Hello can someone give me short tutorial how to:   Remove Windows 7 from my dual boot system (Ubuntu/Windows7) Let me use free space as new partition for data (so I don't need to extend Ubuntu itself here) Remove windows 7 option from boot screen   Update:  Thanks to Lekensteyn answer I successfully deleted windows. Now I created new partition (formatted to ext4), but I can not use it. I cannot copy files there, only as root.  Also when booting, Ubuntu complains it didn't find /windows partition (of course it didn't, I removed it). I feel like I should update some tables or what, any ideas? Is $\langle1-i\rangle$ a maximal ideal in $\mathbb{Z}[i]$? I'm trying to show that $\langle1-i\rangle$ is a maximal ideal of $\mathbb{Z}[i]$.  I started by assuming there is some ideal $A$ that properly contains $\langle1-i\rangle$, and then I want to show that $1 \in A$, and then I will have that $A= \mathbb{Z}[i] $, so $\langle1-i\rangle$ is maximal.  Is this the right approach?  Thanks  Second Attempt: Because $\forall a+bi \in \mathbb{Z}[i]$, we have $a+bi = (a+b) -b(1-i)$, then we have $a+bi - (a+b) = -b(1-i) \in \langle1-i\rangle$, which implies $a+bi +\langle1-i\rangle = a+b +\langle1-i\rangle$.  So every coset is of the form $c +\langle1-i\rangle$, where $c\in \mathbb{R}$.  Furthermore, $-i(1-i)^2=2 \in \langle1-i\rangle$. Write $c = 2q + r$, where $q,r\in \mathbb{R}$ and $r=0,1$.  Then because $2 \in \langle1-i\rangle$, we have $2q\in \langle1-i\rangle$ and therefore $2q= 2q+r-r = c-r\in \langle1-i\rangle$, so $c+\langle1-i\rangle = r+\langle1-i\rangle$, and every coset is of the form $0 + \langle1-i\rangle$ or $1 +\langle1-i\rangle$. Thus, $1 +\langle1-i\rangle$ is the only nonzero element, and is invertible with itself as its inverse.  Thus, $\mathbb{Z}[i]/\langle1-i\rangle$ is a field with two elements, and by a theorem, $\langle1-i\rangle$ must be maximal.  Is this correct? How to encrypt individual folders? How to stop Time Warner cable search on Firefox for Android? I went into about:config and have the following:  browser.search.defaultenginename Google  browser.search.official true  browser.search.order.1 Google  keyword.URL https://www.google.com/search?p=   And still, when I type in the search bar, it pulls up Time Warner Cable Road Runner search instead of Google. It looks like only if I have more than 1 word does it decide to use google -- maybe using only 1 word means I type a malformed URL? How can I fix this to use Google as a proper search engine? Biblatex: submitting to the arXiv I am trying to submit a LaTeX file to the  which uses biblatex.  However, it fails whatever I do.    I first get the message   biblatex.sty is not found   I have tried including (all from TeXLive 2010) biblatex.sty but then I get   logreq.sty is missing then logreq.def is missing   then   ! Package biblatex Error: Outdated 'etoolbox' package.   I then tried adding etoolbox.sty and etoolbox.def and get  ! Package biblatex Error: Style 'alphabetic' not found   So I added alphabetic.bbx then standard.bbx then alphabetic.cbx and finally I get   ! Package biblatex Error: Autocite command 'inline' undefined   I also tried incorporating the bib into the main LaTeX file as in  but it doesn't help.  Has anyone successfully used biblatex with the  and if so, how? Prove that the equation: $c_0+c_1x+\ldots+c_nx^n=0$ has a real solution between 0 and 1. Let $c_0,c_1,c_2,\ldots ,c_n$ be constants such that :  $$c_0+\frac{c_1}{2}+\ldots+\frac{c_{n-1}}{n}+\frac{c_n}{n+1}=0$$  I have to prove that the equation: $$c_0+c_1x+\ldots+c_nx^n=0$$  Has a real solution between 0 and 1.  Didn't know how to start...I thought that maybe I could use something about derivative...But I'm lost... Any help,much appreciated!!! Select first occurring element after another element There is a lemma that says if a group $G$ has no proper nontrivial subgroups, then $G$ is cyclic. And here is the proof of the lemma:     Suppose $G$ has no proper nontrivial subgroups. Take an element $a$ in $G$ for which $a$ is not  equal to $e$. Consider the cyclic subgroup $\langle a \rangle$. This subgroup contains at least $e$ and $a$, so it is not trivial. But $G$ has no proper subgroups, so it must be that $\langle a \rangle = G$. Thus $G$ is cyclic, by definition of a cyclic group.   But here i do not understand the following: Why must $\langle a \rangle$ be a subgroup of $G$? For every single element $a$ in $G$, if $\langle a \rangle$ is a subgroup of $G$, then every group should have at least as many subgroups as the number of its elements. I would appreciate any help. Thanks Which is better: Employer-sponsored HSA or opening an HSA individually? So I know that:   Employer-sponsored HSA's allow you to deduct contributions directly from your paycheck, pre-tax With individual HSAs, you must contribute using post-tax dollars, then deduct those contributions from your taxable income when you do your taxes   Given those facts, I guess it's marginally better to use an employer-sponsored HSA because it means the government doesn't temporarily hold on to your taxed income, only to return it later after you do your taxes; you could theoretically put that money to work in an investment vehicle instead of having the government hold it hostage for a while.  But are there any other benefits (either way) that I'm not aware of? The  kind of threw me with the following statement:     The main advantage of making pre-tax contributions is the Federal Insurance Contributions Act tax (FICA) and Medicare Tax deduction, which amounts to a savings of 7.65% each to the employer and employee (subject to limits of the Social Security Wage Base).   But I'm not really sure what that's telling me.  My employer is offering an HSA, but is not offering to contribute to the HSA or match my contributions. So if it's all pretty much the same, I'd rather use the bank of my choosing and manage it privately.  Thanks. Dimensionality of null space when Trace is Zero This is the fourth part of a four-part problem in Charles W. Curtis's book entitled Linear Algebra, An Introductory Approach (p. 216).  I've succeeded in proving the first three parts, but the most interesting part of the problem eludes me.  Part (a) requires the reader to prove that $\operatorname{Tr}{(AB)} = \operatorname{Tr}{(BA)}$, which I was able to show by writing out each side of the equation using sigma notation.  Part (b) asks the reader to use part (a) to show that similar matrices have the same trace.  If $A$ and $B$ are similar, then  $\operatorname{Tr}{(A)} = \operatorname{Tr}{(S^{-1}BS)}$  $= \operatorname{Tr}(BSS^{-1})$  $= \operatorname{Tr}(B)$,  which completes part (b).  Part (c) asks the reader to show that the vector subspace of matrices with trace equal to zero have dimension $n^2 - 1$.  Curtis provides the hint that the map from $M_n(F)$ to $F$ is a linear transformation.  From this, I used the theorem that $\dim T(V) + \dim n(T) = \dim V$ to obtain the dimension of the null space.  Part (d), however, I'm stuck on.  It asks the reader to show that subspace described in part (c) is generated by matrices of the form $AB - BA$, where $A$ and $B$ are arbitrary $n \times n$ matrices.  I tried to form a basis for the subspace, but wasn't really sure what it would look like since an $n \times n$ matrix has $n^2$ entries in it, but the basis would need $n^2 - 1$ matrixes.  I also tried to think of a linear transformation whose image would have the form of $AB - BA$, but this also didn't help me.  I'm kind of stuck...  Many thanks in advance! Create user ID `root` to force `gedit` to create user configuration file When using sudo powers and calling gedit the top level menu with File Edit View Search Tools Documents Help is missing.  If I create user ID root and sign in once and call gedit will it create the necessary user configuration files that might fix this?  Will this also make the annoying error messages go away whenever I use sudo, gksu or pkexec as a regular user with elevated privileges togedit ?  Will there be other benefits with Nautilus and other Gnome derivative Ubuntu applications?  NOTE: by sudo powers you can google pkexec gedit 3.5k hits, gksu gedit 40k hits or sudo gedit 500k hits. I'm in the minority using the first method but I believe it will become the standard in Ubuntu 17.04.    June 12, 2017 Update Here are a list of errors you get when using pkexec gedit:  (gedit:13003): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files  ** (gedit:13003): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-spell-enabled not supported  ** (gedit:13003): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported  ** (gedit:13003): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-position not supported   On this  there is a commitment to fix these distracting messages as of June 5, 2017. No indication is given for when the fix will be upstream nor if the functionality will be implemented or the error messages will simply disappear.  Note the bug report was filed over a year ago and over that time it only effects 18 people. I usually prefer to fix a Linux system than to reinstall from scratch. My computers have seen many distribution upgrades and a list of PPAs or third-party repositories. APT usually makes sure that everything works in the end. However, the fact that the package manager thinks that all required packages are 'installed' does not guarantee that all the files are present on the file system.  Such a such situation may occur if you have to work-around dependency problems with dpkg --force-*. One could also reproduce such a situation by deleting a file from /usr as root.  Is there a simple way to verify whether all files belonging to an installed package are present?  If a such a problem package is found, aptitude reinstall fixes the problem. I have been learning English for 7 years now, and I have read so many grammar books with rules, telling the difference between Present Perfect and Past Simple and I still find it hard to distinguish them.   On paper, it is easy, if it is not a certain (exact) time in the past without any time markers (yesterday, a month ago, etc) it is past simple. Yes, but outside the classroom it is really harder than this . I have heard many people speaking how they want to, mixing the tenses.   So, I will give these sentences which i have heard to be constructed differently, please, if someone can explain the difference to me.     Have you enjoyed the party? / Did you enjoy the party?      I have given the documents today. / I gave the documents today.      I have done this when I have revised it. / I did it when I revised it      What did you do today? / What have you done today ?   Is it possible to use past simple without mentioning a definite time in the past  (without the time markers)?     It has been 3 years since we moved house. / It has been 3 years since we have moved house.      I know him since we met each other/ I know him since we have met each other   Correct me if some of the sentences are grammatically wrong! I have the following recurrence that I've been pounding on:  $$ a(0)=1\\ a(1)=1\\ a(2)=2\\ a(2n)=a(n)+a(n+1)+n\ \ \ (\forall n&gt;1)\\ a(2n+1)=a(n)+a(n-1)+1\ \ \ (\forall n\ge 1) $$  I don't have much background in solving these things, so I've been googling around looking for different techniques. Unfortunately, I haven't been able to correctly apply them yet. So far I've tried:   Characteristic equations Generating functions Plugging it into Wolfram Alpha Telescoping Observation   I'm sure that one or more of these is the way to go, but my biggest problem right now is figuring out how to deal with the idea that there are different equations for odd and even values of $n$. I'm not necessarily looking for a solution (though it would be gratefully accepted), but any nudges in the right direction would be much appreciated.    To follow up, it turned out that the speed problem described in my comment, below was related to the Decimal implementation in Python 2.7. Switching to Python 3.3 (and Java) made everything many orders of magnitude better. Combinatorics, choosing 3 elements from 100 In how many ways can we pick three different numbers out of the group $1,2,3,\dots,100$ such that the largest number is larger than the product of the two smaller ones? (The order in which we pick the numbers does not matter.) The boundary of union is the union of boundaries when the sets have disjoint closures Using lasso for feature selection, followed by a non-regularized regression I use Lasso logistic regression in order to identify a smaller subset of important variables. I start with N=51 (28/23) and 32 predictors.   So far it looks pretty promising, because I can identify four important predictors in my optimal model.   Now I would like to take those four predictors and examine them along with some control variables in a standard logistic regression.   My question is, does that analysis strategy make sense? Is there a better way to include controls or other variables that might be interesting?  For a better understanding:   Identify important variables via Lasso logistic regression Do further analysis including identified predictors and other control variables using standard logistic regression (using AIC to check model fit) There are a couple of different ways to remove HTML tags from an NSString in Cocoa.   is to render the string into an NSAttributedString and then grab the rendered text.   is to use NSXMLDocument's -objectByApplyingXSLTString method to apply an XSLT transform that does it.  Unfortunately, the iPhone doesn't support NSAttributedString or NSXMLDocument. There are too many edge cases and malformed HTML documents for me to feel comfortable using regex or NSScanner. Does anyone have a solution to this?  One suggestion has been to simply look for opening and closing tag characters, this method won't work except for very trivial cases.   For example these cases (from the Perl Cookbook chapter on the same subject) would break this method:  &lt;IMG SRC = "foo.gif" ALT = "A &gt; B"&gt;  &lt;!-- &lt;A comment&gt; --&gt;  &lt;script&gt;if (a&lt;b &amp;&amp; a&gt;c)&lt;/script&gt;  &lt;![INCLUDE CDATA [ &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ]]&gt; How can I suppress all output from a command using Bash? I have a Bash script that runs a program with parameters.  That program outputs some status (doing this, doing that...). There isn't any option for this program to be quiet. How can I prevent the script from displaying anything?  I am looking for something like Windows' . In Data Extension one field 'HTML' have Data that I have shown below, Now I have to Find the 'Href', and and at the last of URL append some text like '&amp;MC='. It may have Multiple 'Href'. Please help me on this.   &lt;table width="540" style="margin: 0px; padding: 0px;" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0"&gt;  &lt;tbody&gt;   &lt;tr&gt;    &lt;td valign="top"&gt;    &lt;h5 style="margin: 0px; padding: 0px 0px 2px; line-height: normal; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-weight: normal;"&gt;    &lt;a style="text-decoration: none;" href="https://test.4.com/testRegistration/testLobbyServlet?target=reg20.jsp&amp;eventid=897605&amp;sessionid=1&amp;key=2F3D1EB963D9DB7738BF2877DFFDBA01&amp;partnerref=Social&amp;sourcepage=register&amp;loc=zOTlocz&amp;prod=zWAz&amp;tech=zsecz&amp;prog=zOTprogz&amp;type=zOTtypez&amp;media=zWCz&amp;country=zUSz" alias="Success with Enterprise Mobility: Making email and Office 365 secure on mobile devices"&gt;    Success with Enterprise Mobility: Making email and Office 365 secure on mobile devices     &lt;/a&gt;    &lt;/h5&gt;    &lt;p style="margin: 0px; padding: 0px; line-height: 20px; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal;"&gt;    &lt;span style="color: rgb(103, 103, 103);"&gt;    &lt;em&gt;December 9, 2014, 10:30 A.M.&amp;ndash;11:30 A.M. Pacific Time&lt;/em&gt;&lt;br&gt;    An enterprise mobility strategy involves identity, management, and productivity. In this session featuring Brad Anderson, you will learn about the integration and the Office mobile apps while enabling secure mobile productivity.    &lt;/span&gt;    &lt;/p&gt;    &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td valign="top"&gt;&amp;nbsp;    &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td valign="top"&gt;    &lt;h5 style="margin: 0px; padding: 0px 0px 2px; line-height: normal; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-weight: normal;"&gt;    &lt;a style="text-decoration: none;" href="http://test.TTr.com/?Wt.mc_id=IG15W2NWTN&amp;loc=zOTlocz&amp;prod=zWAz&amp;prod=zWSz&amp;tech=zCLz&amp;prog=zOTprogz&amp;type=zEVz&amp;media=zOTmediaz&amp;country=zUSz" alias="Test: Everything about enterprise technology under one roof"&gt;    Test: Everything about enterprise technology under one roof    &lt;/a&gt;    &lt;/h5&gt;    &lt;p style="margin: 0px; padding: 0px; line-height: 20px; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal;"&gt;    &lt;span style="color: rgb(103, 103, 103);"&gt;    &lt;em&gt;May 4&amp;ndash;8, 2015, Chicago, IL&lt;/em&gt;&lt;br&gt;    If you&amp;rsquo;re serious about technology, you don&amp;rsquo;t want to miss Test. This event will be the intersection of everything in enterprise technology. Get ahead in your job and your career.    &lt;/span&gt;    &lt;/p&gt;    &lt;/td&gt;   &lt;/tr&gt;  &lt;/tbody&gt; &lt;/table&gt;