title: How to set a environment variable in the current shell with Python?
body: <p>I want to set an environment variable with a <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="noreferrer">Python</a> script, influencing the shell I am starting the script in. Here is what I mean</p>
  
  <pre><code>python -c "import os;os.system('export TESTW=1')"
  </code></pre>
  
  <p>But the command</p>
  
  <pre><code>echo ${TESTW}
  </code></pre>
  
  <p>returns nothing. Also with the expression </p>
  
  <pre><code>python -c "import os;os.environ['TEST']='1'"
  </code></pre>
  
  <p>it does not work. </p>
  
  <p>Is there another way to do this in the direct sense? Or is it better to write the variables in a file which I execute from 'outside' of the Python script?</p>