I need to create an environment variable in python that will out last the life of the process creating it preferably in a non os-dependent way i.e if I ran : create_env_var.py (example non active code )
#/my/path/create_env_var.py
import module_that_fixes_my_problem as easy_fix
easy_fix.create_environment_variable(name_of_var = "ENV_VAR",value_of_var="this was easy")
and then ran read_env_var.py
#/my/path/read_env_var.py
import module_that_fixes_my_problem as easy_fix
my_var = easy_fix.read_environment_variable(name_of_var = "ENV_VAR")
print(my_var) # "this was easy"
I have tried doing this using os.environ like this :
os.environ['ENV_VAR'] = "this was easy"
but on a Windows machine I couldn't create a lasting environment var and on a Linux machine it would not last outside of the life of the process as described here :