title: Access global variables from a function in an imported module
body: <p>I have a function that i'm calling from module. Within the function the two variables i'm trying to access are made global. When I run the module in IDLE by itself I can still access the variables after the function ends, as expected. When I call the function in the  code that I have imported the module into I can't access the variables.</p>
  
  <pre><code>#module to be imported
  
  def globaltest():
      global name
      global age
      name = str(raw_input("What is your name? "))
      age = int(raw_input("What is your age? "))
  </code></pre>
  
  <p>The output when I run it by itself.</p>
  
  <pre><code>&gt;&gt;&gt; globaltest()
  What is your name? tom
  What is your age? 16
  &gt;&gt;&gt; name
  'tom'
  &gt;&gt;&gt; age
  16
  </code></pre>
  
  <p>And the code where import it.</p>
  
  <pre><code>import name_age
  
  name_age.globaltest()
  </code></pre>
  
  <p>but when I run attempt to access the variables in the code where I have imported it.</p>
  
  <pre><code>What is your name? tom
  What is your age? 16
  &gt;&gt;&gt; name
  
  Traceback (most recent call last):
  File "&lt;pyshell#10&gt;", line 1, in &lt;module&gt;
   name
  NameError: name 'name' is not defined
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>How can I make the variable global in the code where I have imported the module or access the 'name' or 'age' variables in the function.</p>