title: What does if __name__ == "__main__": do?
body: <p>What does this do, and why should one include the <code>if</code> statement?</p>
  <pre><code>if __name__ == &quot;__main__&quot;:
      print(&quot;Hello, World!&quot;)
  </code></pre>
  <hr />
  <p><sub>This question explains what the code does and how it works. If you are trying to close a question where someone should be using this idiom and isn't, consider closing as a duplicate of <a href="https://stackoverflow.com/questions/6523791">Why is Python running my module when I import it, and how do I stop it?</a> instead.</sub></p>