I'm completely new to Python and thus a bit confused about the flow of a program in Python. If my understanding is correct, for a single .py file, if we add the line  if __name__ =="__main__": main()   The interpreter finds the main function and starts executing from there. This, since Python execution goes sequentially line after line.  My question is if there are multiple .py files and 1 such file has the main function, like Java/C++ is there a way the python interpreter can know ad start executing the main function?
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))
Uniform distribution on the surface of unit sphere Different mechanics of \hyperlink vs. \hyperref I am fiddling around with the hyperref package to build a hypertext structure into my pdf. At first glance, hyperref provides two similar macros to put links between parts of my document: \hyperlink{target}{text} and \hyperref[target]{text}. You might notice their slightly different syntax. What really interests me is their different working mechanics. I will illustrate this by the following example: \documentclass{article}  \usepackage{pdfpages} \usepackage[]{hyperref} \usepackage{mwe}  \begin{document}  \section{Section Heading} \label{sectionheading}  \includepdf[link=true, linkname=pdfpage]{example-image}   Link to section works with \hyperref[sectionheading]{hyperref} and with \hyperlink{sectionheading}{hyperlink} (but with slightly different targets on the page).  Link to pdf works with \hyperlink{pdfpage.1}{hyperlink} but not with \hyperref[pdfpage.1]{hyperref} (and not this way, either: \hyperref[pdfpage]{hyperref}).  \end{document}  To link to the labeled section heading, I may use both commands. While \hyperref directs my pdf viewer directly to the linked section, \hyperlink directs me somewhere slightly different, so I can see more context. To link to the \includepdf of pdfpages however, I may only use \hyperlink. \hyperref does not work at all. I suspect this is because of a subtle difference in their working mechanisms. While checking the aux file, I found a line \newlabel{sectionheading}{{1}{1}{Section Heading}{section.1}{}} which \hyperref seems to use as a target. However, I did not find any similar target for the included pdf. My question: I suspect, I understand the workings of \label and \ref very well. \hyperref seems to work quite similarly with the added clickability. Could you please explain to me how \hyperlink does work differently and how it is implemented? E.g. what mechanics explain the difference when clicked on the link and where and how are the link targets stored in the first place? Why can I no longer easily navigate inside of this mesh? Is it really impossible to calculate in advance the result of throwing dice? What makes the inside of a shape the inside? The problem Comments are terrible; no one agrees on what they're for, or how long they should be kept. Comment flags are equally terrible, because if no one's on the same page as far as what should be posted in the first place then no one can agree on what should be removed either. On top of that, we have this confusing set of flags where two mean &quot;noise&quot;, one means &quot;vile&quot;, one means &quot;moderator, help!&quot; and one means nothing at all - the end result is that it's all but impossible to even analyze comment flagging. The solution (or, part of it) Two years ago, in a fit of rage, I . Nothing got done. As always, everyone has a different idea of how things are supposed to work, and I'd bitten off more than I could chew. So, here we are, two years later, and comment flags still suck. So let's start by just cutting the fat: if we can trim down the list of flags to a set of clearly distinct problems, we might have something we can build on. Here's what I'm proposing, based on the past two years of discussion:   Re-word the &quot;rude or offensive&quot; flag to read,  rude or abusive: this comment violates .   Remove the &quot;not constructive&quot;, &quot;obsolete&quot; and &quot;too chatty&quot; flags.  Add a new comment flag:  no longer needed: this comment is obsolete, chatty or otherwise unnecessary   Re-word the &quot;other...&quot; flag:  in need of moderator attention: these comments require action by a moderator. Be specific and detailed!    That's it; that's all I'm proposing to start out - simplify things so that we have something to build on. See also: How to change plot style or other options after it was created Does JavaScript have the interface type (such as Java's 'interface')? Changing Login Logo After modifying the code in my functions.php file to display a different logo on my login page, I'm getting a blank square instead.  I've added a custom .png image (326x67) to my (child) theme's image folder, and the code I've added to functions.php is as follows:  function custom_loginlogo() {     echo '&lt;style type="text/css"&gt;     h1 a {background-image: url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }     &lt;/style&gt;'; } add_action('login_head', 'custom_loginlogo');   Could it be a permissions problem (like an .htaccess file blocking the image)? The final state of 1000 light bulbs switched on/off by 1000 people passing by What is the Big-O time complexity of the following nested loops: for (int i = 0; i &lt; N; i++) {     for (int j = i + 1; j &lt; N; j++) {         System.out.println(&quot;i = &quot; + i + &quot; j = &quot; + j);     } }  Would it be O(N^2) still? I always see commands like this  apt-get -y install    What is the -y tag for and what is the difference between apt-get install with and without the -y tag? I have a very strange behavior on an Android device (Nexus 7) when trying to access local network applications. Instead of getting the actual IP of the machine on LAN, the Android device gets the public IP, which means that Chrome, Firefox or any other browser simply shows the web page of the router.  I have an internal DNS server which handles the local networks. Doing ping from a PC works correctly:  $ ping s.pelicandd.com  PING pelicandd.com (192.168.1.15) 56(84) bytes of data. 64 bytes from front.pelicandd.com (192.168.1.15): icmp_seq=1 ttl=64 time=0.524 ms 64 bytes from front.pelicandd.com (192.168.1.15): icmp_seq=2 ttl=64 time=0.578 ms ^C   On an HTC One device (accessed with adb shell), it works well too:  shell@m7:/ $ ping s.pelicandd.com  PING pelicandd.com (192.168.1.15) 56(84) bytes of data. 64 bytes from front.pelicandd.com (192.168.1.15): icmp_seq=1 ttl=64 time=2.56 ms 64 bytes from front.pelicandd.com (192.168.1.15): icmp_seq=2 ttl=64 time=27.8 ms ^C   However, this is what I get when doing the same ping from Nexus 7:  shell@flo:/ $ ping s.pelicandd.com  PING pelicandd.com (90.78.26.42) 56(84) bytes of data. 64 bytes from LFbn-1-2441-42.w90-78.abo.wanadoo.fr (90.78.26.42): icmp_seq=1 ttl=64 time=2.56 ms 64 bytes from LFbn-1-2441-42.w90-78.abo.wanadoo.fr (90.78.26.42): icmp_seq=2 ttl=64 time=8.63 ms ^C   Instead of resolving to the internal IP, it resolves to the public one.  The network configuration is—except the IP address of the device—exactly the same on both devices: IP settings are set to Static, and DNS servers are the internal ones. Both Android devices are connected through Wi-Fi (unlike the PC). A major difference, however, is that Nexus 7 is using Android 6.0.1, while HTC One uses Android 5.0.2.  There is no nm-tool, dig or nslookup on Nexus 7. The device is not rooted.  The problem existed since I bought the device a few weeks ago, so it could hardly be the issue with DNS cache.  What can I do to further inspect this issue? Explicit bijection between $\Bbb R$ and permutations of $\Bbb N$ Why is $\frac{1}{\frac{1}{0}}$ undefined? Why is AES unbreakable? Display Custom Fields in a SharePoint 2010 Content Query Web Part Using SharePoint 2010, Having Custom List With 4 Columns, Now I am Using Content Query Web-part To Display List Data ,But Currently It Display Only First Column, SO How to Display Custom Fields in a SharePoint 2010 Content By Query Web Part How to make the measuring grid larger? When starting the blender, there is always a cube on the floor. The floor is actually a grid. My question is how to make this grid bigger so that we can measure big stuff? I understood the very basic concept of how to use /etc/network/interfaces, but all I find online are examples, example after example, which I can copy-paste from. What I miss is an explanation of the syntax, an explanation of the meaning of the commands and which order the commands require. I want to understand, because most of the time copy-paste is not enough, because I'm not working on a fresh machine, so I can't just overwrite existing configurations because it would break a lot of stuff. man interfaces was not very helpful since it is written very complicated.  Example questions I have: what does inet in an iface line mean exactly (I could not even find it in the manpage), what does manual in an iface line mean exactly (many examples use it, but according to manpage it needs an extra config file then, which the examples don't present), when do I use or need them? When not? When I create a bridge, what exactly happens to the interfaces? How do I calculate the date six months from the current date using the datetime Python module?