title: Send value of variable that is in a loop from one script to another script
body: <p>I've been fiddling with sending a variable from one script to another and have done some basic things pretty easily, but I have gotten stuck and was hoping to get some input.</p>
  
  <p>This is my script1.py</p>
  
  <pre><code>import time
  x = 0
  
  while x &lt; 100:
      x = x+1
      time.sleep(1)
  </code></pre>
  
  <p>This is my script2.py</p>
  
  <pre><code>import subprocess
  
  subprocess.Popen("python script1.py", shell=True)
  
  from script1 import x
  
  print(x)
  </code></pre>
  
  <p>The output of this is just 100.</p>
  
  <p>Is there a way to print the variable <code>x</code> every time it gets updated through script2.py?</p>
  
  <p>The reason for all of this is I am reading data from a serial port in a script but I want to use the output in a different script whenever it comes in. So essentially, whenever there is data available from the serial port stored in a variable I want that variable passed to another script.</p>
  
  <p>EDIT: I have a python script where it script reads data from one serial port and logs the data.</p>
  
  <p>With that being said, I want a second script that can take the list containing the data from the first script in order to manipulate it for a different task.</p>
  
  <p>EDIT 2:
  I have modified the code as follows, but nothing prints. </p>
  
  <pre><code>#script 1
  import time
  x = 0
  
  while x &lt; 100:
      x = x+1
      print(x)
      time.sleep(1)
  
  #script 2
  import subprocess
  
  proc = subprocess.Popen(['python','script1.py'],stdout=subprocess.PIPE)
  
  while True:
      line = proc.stdout.readline()
      print(line)
  </code></pre>