Suppose created an environment variable in your Python script (which is a process). Is the lifetime of the environment variable the same as the lifetime of the script while it runs? I've set my environment variable and ran my Python code until completion and if I tried to do
echo $MY_CREATED_ENV_VAR
it returns empty. I know that my script creates this environment variable because I could use it within the script itself.
Here is part of the script
import os
os.environ['MY_CREATED_ENV_VAR'] = "1"
# Returns-> MY_CREATED_ENV_VAR = 1 (and usable by other processes in the script)
print("MY_CREATED_ENV_VAR = " + os.environ["MY_CREATED_ENV_VAR"])
# Script ends
does MY_CREATED_ENV_VAR automatically become unset? If not, how would I manually unset this environment variable in the script so as to clean up my code?
Thanks in advance!
Edit: I see that you can unset the variable, but then my question still stands, does python automatically unset the environmental variables? I cannot echo the env variable back in my terminal after the script has finished executing.