Category Archives : python

Python – importing bash environment variables

I’ve run into situations where it was necessary to read the values of bash environment variables defined in a file into a python script. Something like that is achieved in bash simply by doing: source env.vars or . env.vars Where the content of env.vars could be something like this: BASE=/home/user/scripts BIN_DIR=$BASE/bin VAR1=xxxxx VAR2=yyyy The solutions […]