title: Export a variable from bash and use it in Python
body: <p>I am trying to write a script which is executing couple of things on a Linux server and I would like to use bash for most of the Linux specific commands and only use Python for the most complex stuff, but in order to do that I will need to export some variables from the bash script and use them in the python script and I didn't find a way how I can do that. So I have tried to create two very little scripts to test this functionality: 
  1.sh is a bash script</p>
  
  <pre><code>#!/bin/bash
  
  test_var="Test Variable"
  export test_var
  echo "1.sh has been executed"
  python 2.sh
  </code></pre>
  
  <p>2.sh is a Python script: </p>
  
  <pre><code>#!/usr/bin/env python3
  
  print("The python script has been invoked successfully")
  print(test_var)
  </code></pre>
  
  <p>As you can guess when I execute the first script the second fails with the error about unknown variable: </p>
  
  <pre><code>$ ./1.sh
  1.sh has been executed
  The python script has been invoked successfully
  Traceback (most recent call last):
    File "2.sh", line 4, in &lt;module&gt;
      print(test_var)
  NameError: name 'test_var' is not defined
  </code></pre>
  
  <p>The reason why I am trying to do that is because I am more comfortable with bash and I want to use $1, $2 variables in bash. Is this also possible in Python? </p>
  
  <p>[EDIT] - I have just found out how I can use $1 and $2 it in Python. You need to use <code>sys.argv[1]</code> and <code>sys.argv[2]</code> and import the sys module <code>import sys</code></p>