title: Can I run a bash script in Python and keep any env variables it exports?
body: <p>The title pretty much says it all..</p>
  
  <p>Suppose I have a bash script:</p>
  
  <pre><code>#!/bin/bash
  
  # do some magic here, perhaps fetch something with wget, and then:
  if [ "$VAR1" = "foo" ]; then
      export CASEVARA=1
  fi
  export CASEVARB=2
  
  # and potentially many other vars...
  </code></pre>
  
  <p>How can I run this script from python and check what env variables were set. Ideally, I'd like to "reverse-inherit" them into the main environment that is running Python.</p>
  
  <p>So that I can access them with</p>
  
  <pre><code>import os
  
  # run the bash script somehow
  
  print os.environ['CASEVARA']
  </code></pre>