Two variations of Python's main function
<p>When writing scripts for personal use, I am used to doing this:</p>

<pre><code>def do_something():
    # Do something.

if __name__ == '__main__':
    do_something()
</code></pre>

<p>Or, we can also do this:</p>

<pre><code>def do_something(): 
    # Do something.  

do_something()      # No if __name__ thingy. 
</code></pre>

<p>I know the first form is useful when differentiating between importing the script as a module or calling it directly, but otherwise for scripts that will only be executed (and never imported), is there any reason to prefer one over the other?</p>
