In shell script , I'm able to export a variable. How do I do the same in Python
Shell code:
PYTHON_PATH=`which python`
PYTHON_PATH=`dirname $PYTHON_PATH`
PATH=/bin:/usr/bin
export PATH=~/.local/bin:$PATH:$PYTHON_PATH
Python code:(Version - 2.7)
PYTHON_PATH = subprocess.check_output("which python", shell=True)
PYTHON_PATH = os.path.dirname(PYTHON_PATH)
PATH = os.path.expanduser('~') + "/.local/bin:" + PATH + ":" + PYTHON_PATH
subprocess.call('export PATH="{}"'.format(PATH), shell=True)
Is this right way to export a PATH
variable in python.