On Tue, 27 Jul 2010 00:36:12 +0100, Peng Yu <pengyu...@gmail.com> wrote:
R_HOME is set in my shell (bash). But os.environ doesn't have it. I'm not sure what it does when os module is imported. But it seems that os.environ doesn't capture all the environment variable from the shell. Could anybody let me know what is the correct way to inherent all the environment variables form the shell?
os.environ does capture all the environment that the shell passes to it. In this case, you haven't exported R_HOME, so the shell doesn't export it, so os.environ has no chance to capture it. rho...@gnudebst:~$ HELLO=world rho...@gnudebst:~$ echo $HELLO world rho...@gnudebst:~$ export HELLO rho...@gnudebst:~$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import os os.environ['HELLO']
'world' -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list