title: How to pass variables in parent to subprocess in python?
body: <p>I am trying to have a parent python script sent variables to a child script to help me speed-up and automate video analysis. </p>
  
  <p>I am now using the <code>subprocess.Popen()</code> call to start-up 6 instances of a child script but cannot find a way to pass variables and modules already called for in the parent to the child. For example, the parent file would have:</p>
  
  <pre><code>import sys
  import subprocess
  parent_dir = os.path.realpath(sys.argv[0])
  subprocess.Popen(sys.executable, 'analysis.py')
  </code></pre>
  
  <p>but then <code>import sys; import subprocess; parent_dir</code> have to be called again in "analysis.py". Is there a way to pass them to the child?</p>
  
  <p>In short, what I am trying to achieve is: I have a folder with a couple hundred video files. I want the parent python script to list the video files and start up to 6 parallel instances of an analysis script that each analyse one video file. If there are no more files to be analysed the parent file stops.</p>