I was wondering what does if __name__ == "__main__": really do in python, I have the following code in python3:  def main():     test();  def test():     print("hello world " + __name__);  if __name__ == "__main__":     main();   we know that we have to declare a function before we use it, so function call inside of if part works fine, the main() is defined before it is called inside of if statement, but what about the test() function, it is defined after it is called and there is no errors:  def main():     test();  def test():     print("hello world " + __name__);   so how could it works if the test() function is defined after it is called?
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))
Can I see why a package is installed? I read recently that you can find the number of digits in a number through the formula $\lfloor \log_{10} n \rfloor +1$ What's the logic behind this rather what's the proof? Why are there so many different ways to measure disk usage? When I sum up the sizes of my files, I get one figure. If I run du, I get another figure. If I run du on all the files on my partition, it doesn't match what df claims is used. Why are there so many different figures for the total size of my files? Can't computers add?  Speaking of adding: when I add the “Used” and “Available” columns of df, I don't get the total figure. And that total figure is smaller than the size of my partition. And if I add up my partition sizes I don't get my disk size! What gives? Should questions having lots of downvotes be downvoted further? Is down-voting an already heavily down-voted/closed question kind of like kicking a dead horse? Is this bad practice? Prove the inequality $\,\frac{1}{\sqrt{1}+ \sqrt{3}} +\frac{1}{\sqrt{5}+ \sqrt{7} }+\ldots+\frac{1}{\sqrt{9997}+\sqrt{9999}}\gt 24$ Prove the inequality $$\frac{1}{\sqrt{1}+ \sqrt{3}}  +\frac{1}{\sqrt{5}+ \sqrt{7} }+......... +\frac{1}{\sqrt{9997}+\sqrt{9999}} &gt; 24$$   My work:   Rationalizing the denominator gives   $$\frac{\sqrt{3}-1}{2}  +\frac{\sqrt{7}-\sqrt{5}}{2}+......+\frac{\sqrt{9999}-\sqrt{9997}}{2} .$$  Now by taking two as common and separating the positive and negative terms gives  $$\frac{1}{2} [ \{\sqrt{3} +\sqrt{7}+\dots +\sqrt{9999}\} - \{1+\sqrt{5} +\dots+\sqrt{9997}\}].$$  Can we do like this please suggest. Thanks. Handling large numbers in C++? What is the best way to handle large numeric inputs in C++ (for example 10^100)?   For algorithms I usually switch over to ruby and I sometimes use strings.  Any other good methods? $M + N$ and $M \cap N$ are finitely generated $A$-modules implies $M$ and $N$ finitely generated using exact sequences Let $0 \to M_1 \to M \to M_2 \to 0$ be an exact sequence of $A$-modules.  i) Prove: If $M_1$ and $M_2$ are finitely generated, then $M$ is too.  ii) Let $M$ and $N$ be sub-modules of an $A$-module $L$. Assume that $M+N$ and $M\cap N$  are finitely generated $A$-modules. Prove that $M$ and $N$ are finitely generated $A$-modules.  If have proved the first part, but i don't see how to do the second part. I tried to use the first part, so to find an exact sequence with $M$ in the middle and finitely generated modules in place of $M_1$ and $M_2$, but I can't find a surjective map $M \to P$ (for some f.g. $A$-module) in the sequence:  $$0 \to M\cap N \to M \to P \to 0$$  any hints/help would be appreciated. H2G2 — Teleportation Also Results in Time Travel? Class moderncv moving footer I am using documentclass moderncv to style my resume, and I'd like to put the information that normally goes at the bottom of the document, such as phone number and email, to the space next to the name aligned on the left of the document. I'm a beginnner user, so I'd love to get some enlightenment on this.  \documentclass[11pt,letterpaper,sans]{moderncv}  % moderncv themes \moderncvstyle{casual} \moderncvcolor{blue} \usepackage[scale=0.75]{geometry}  % personal data \firstname{John} \familyname{Doe} \mobile{+1~(234)~567~890}  % content  \begin{document} \makecvtitle \pagestyle{empty}  \section{Education} \cventry{1998-2007}{Degree}{Institution}{City}{\textit{Grade}}{Description}   \section{Computer skills}  \thispagestyle{plain} \end{document}    Simply put, I want to move \mobile from the bottom to the top left. What item bonuses apply to my follower? There are a lot of different side effects an item can have, and I assume that things like magic find have no influence on any of "our" found items at all.  However, I'm not sure about other things. For example:   Do followers get life-steal on weapons, too? Does increased orb healing make any difference? What about +experience after kills? Will my follower level up faster?   and probably a lot more.  Is there some general rule as to what effects of an item apply to followers, and which don't? This works perfectly:  $ inotifywait --event create ~/foo Setting up watches. Watches established. /home/ron/foo/ CREATE bar   However, this just sits there when directory tun0 is created under /sys/devices/virtual/net.  $ inotifywait --event create /sys/devices/virtual/net Setting up watches. Watches established.   Since those folders are world readable, I'd expect inotifywait to work.  So, what am I doing wrong?  Thanks Using headset controls like a smart phone I have a generic pair of smartphone earphones that have the button (along with a microphone) and I would like to use the button as a pause/play key in Ubuntu, like I would on an Android phones music player.  Is there a way to enable this headset control in Ubuntu?  If the headset controls are a hardware feature of audio jacks used in Android phones, the name of that hardware (audio jack) would be appreciated. Is this an equivalent formulation of "surjective" resp. "epimorphism"? Wulfgar won't teach me Unrelenting Force's final word after Arngeir accepts the Horn of Jurgen Windcaller For what powers $k$ is the polynomial $n^k-1$ divisible by $(n-1)^2$? How do you prove this?  $$\left(n-1\right)^2\mid\left(n^k-1\right)\Longleftrightarrow\left(n-1\right)\mid k$$ Unity doesn't load, no Launcher, no Dash appears When I login, nothing happens.   I am presented with my desktop wallpaper.    No Dash, no Launcher, nothing. When typesetting URLs in LaTeX using the url package, they are set in a mono space font by default. While I just accepted that as a fact for a long time, I am now starting to wonder why?  In Browsers, for example, the URL in the address bar is also not monospace. It does not make the link more readable, in my opinion rather on the contrary. The only explanation I can come up with is that it sets the link apart from the remeaining text. But honestly, even that sometimes looks a bit obstrusive.  So is the reasons really just to set links apart from the text? How to set a proxy for terminal? I am looking to set a proxy for terminal. What I need is I want to send all terminal communications to the internet through a proxy, say tor.   I tried to set a system wide proxy set up. But Terminal doesn't obey the system wide proxy configuration.  Is there any other way to do this? Why "think bright" is used with adjective instead of adverb (think brightly)? I find "think bright" is much more common usage, but why? In my opinion, "Think" is a verb, so it is reasonable to use adverb to describe it.  Examples:      THINK BRIGHT!      The National University of Science and Technology MISIS   () When should one use "should" and when should one use "must"? I tend to use should when it's a suggestion I don't have a strong opinion on, i.e. it could be done in many other ways than the one I'm suggesting and it can still happen.     You should stop by that gas station to go to the bathroom.   On the other hand, I usually use must for things that have to happen in a certain way; any other way would make that thing not to happen. The problem is that some people find this usage harsh, as they receive it like if I'm giving them an order.      You must cross the street to get to that store.   To me, it's just a depiction of reality, not an order. But I'm neither a native speaker nor a regular person. :-)  So, what's the proper use for must and should? Does this use differ among the English dialects?