title: Does Python automatically unset environmental variables at the end of the script?
body: <p>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 </p>
  
  <blockquote>
    <p>echo $MY_CREATED_ENV_VAR</p>
  </blockquote>
  
  <p>it returns empty. I know that my script creates this environment variable because I could use it within the script itself.</p>
  
  <p>Here is part of the script</p>
  
  <pre><code>import os
  
  os.environ['MY_CREATED_ENV_VAR'] = "1"
  
  # Returns-&gt; 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
  </code></pre>
  
  <p>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?</p>
  
  <p>Thanks in advance!</p>
  
  <p>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.</p>