title: Python main function
body: <p>I came across a line in python:</p>
  
  <pre><code>def somefunc:
      [...]
  
  if __name__ == '__main__':
      somefunc
  </code></pre>
  
  <p>I don't understand what the "if __name ..." does.</p>
  
  <p>Suppose we have:</p>
  
  <pre><code>if __name__ == '__main__': main()
  
  #this code will find main
  </code></pre>
  
  <p>So is this similar to the main() function in C/C++, which gets executed before any other function?</p>