os.putenv ?

Chermside, Michael mchermside at ingdirect.com
Wed Mar 26 12:43:36 EST 2003


>  > cat > grrr.py
>  import os
>  os.putenv("GRRR","This is a late parrot.")
>  print "GRRR has been set to:", os.getenv("GRRR")
>  > echo $GRRR
>  
>  > python grrr.py 
>  GRRR has been set to: None
>  > echo $GRRR
>  
>  
>  What am I missing ?

While the answer may vary some from OS to OS, in many commonly
used OSes (eg: unixes) a process may set its OWN environment,
and it may set the environment of its CHILD processes, but it
cannot set the environment of its PARENT process. That's why
in unix "ls" is written as a separate program, but "setenv" is
built into the shell (if it were a separate program, the
program could set its own environment, but not that of the
shell (its parent)).

So what you're asking for is impossible (intentionally) in
any language (not just Python). What are you trying to achieve?
Perhaps there's a better way.

-- Michael Chermside


This email may contain confidential or privileged information. If you believe you have received the message in error, please notify the sender and delete the message without copying or disclosing it.






More information about the Python-list mailing list