Environment Variable

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Mon Jul 11 17:25:21 EDT 2005


tuxlover at gmail.com wrote:
> Is it possible to set an environment variable from inside the python
> script which will be retained after the script exits.
> 
> If I use the following code:
> 
> import os
> os.putvar("name", "tuxlover")
> 
> the enivironment variable name is visible to only the sub-process
> created by os.system and os.popen. But as soon as the python script
> vanishes, the environment variable "name" is gone.
> 
> What I am wondering is that is it possible to set a environment
> variable from inside a python script, and then access it (say, echo
> $name from the shell) after the python script exits.

No, I regret it is currently not. But I see a significant chance that
someone gets on the time machine and implants this into Thompson's head
some 30 years earlier as soon as you post that a third time.

Reinhold



More information about the Python-list mailing list