Setting environment variables

Erik Max Francis max at
Thu Sep 18 09:07:31 CEST 2003

Sami Viitanen wrote:

> Is there any other way to set variables than os.putenv().
> Putenv doesn't actually put any values to actual system variables..
> I'm trying to set CVSEDITOR variable automatically from script
> so that user wouldn't have to set that him/herself. CVS can't use
> variable
> set with putenv().

Yep, and this is a feature, at least in Unix operating systems. 
Subshells cannot directly affect the operating environment of parent
shells, and shouldn't try.  (One can do such things indirectly, but they
require the cooperation of the parent shell, such as sourcing the output
of a program, which is not an uncommon approach to the problem.)  I
don't know if there's any way for Windows applications to affect parent
environments, but I doubt it.

   Erik Max Francis && max at &&
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Perfect situations must go wrong
\__/  Florence, _Chess_

More information about the Python-list mailing list