title: Pass variable between python scripts
body: <p>I'm sure this is very simple but I've been unable to get it working correctly. I need to have my main python script call another python script and pass variables from the original script to the script that I've called </p>
  
  <p>So for a simplistic example my first script is, </p>
  
  <pre><code>first.py
  x = 5
  import second
  </code></pre>
  
  <p>and my second script is, </p>
  
  <pre><code>second.py 
  print x
  </code></pre>
  
  <p>and I would expect it to print x but I get</p>
  
  <pre><code>NameError: name 'x' is not defined
  </code></pre>
  
  <p>I'm not sure if import is right way to achieve this, but if someone could shed light on it in a simple way that would be great!</p>
  
  <p>thanks,</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>After reading the comments I thought I would expand on my question. Aswin Murugesh answer fixes the import problem I was having, however the solution does not have the desired outcome as I can not seem to pass items in a list this way. </p>
  
  <p>In first.py I have a list which I process as follows </p>
  
  <pre><code>for insert, (list) in enumerate(list, start =1):
      'call second.py passing current list item'
  </code></pre>
  
  <p>I wanted to pass each item in the list to a second python file for further processing (web scraping), I didn't want to do this in first.py as this is meant to be the main 'scan' program which then calls other programs. I hope this now make more sense. </p>
  
  <p>Thanks for the comments thus far. </p>