title: python globals: import vs. execfile
body: <p>I put a method in a file mymodule.py:</p>
  
  <pre><code>def do_something():
      global a
      a=1
  </code></pre>
  
  <p>If I try</p>
  
  <pre><code>&gt;&gt;&gt; execfile('mymodule.py')
  &gt;&gt;&gt; do_something()
  &gt;&gt;&gt; print a
  </code></pre>
  
  <p>I get "1" as I expect.  But if I import the module instead, </p>
  
  <pre><code>&gt;&gt;&gt; from mymodule import *
  </code></pre>
  
  <p>and then run do_something(), then the python session knows nothing about the variable "a".</p>
  
  <p>Can anyone explain the difference to me?  Thanks.</p>