Using os module I can get the values of the environment variables. For example:
os.environ[\'HOME\']
However, I cannot set the
If what you want is to make your environment variables persist accross sessions, you could
For unix
do what we do when in bash shell. Append you environment variables inside the ~/.bashrc.
import os
with open(os.path.expanduser("~/.bashrc"), "a") as outfile:
# 'a' stands for "append"
outfile.write("export MYVAR=MYVALUE")
or for Windows:
setx /M MYVAR "MYVALUE"
in a *.bat that is in Startup in Program Files
I am not sure. You can return the variable and set it that way. To do this print it.
(python program)
...
print foo
(bash)
set -- $(python test.py)
foo=$1