By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Problem using os.environ.get

P: n/a
Hello,

I am trying to retrieve a linux environment variable using
os.environ.get, however it does not appear to be working properly. It
returns none for a variable that does, in fact exist.

# echo $HOSTTYPE
x86_64
# python
>>import os
print os.environ.get('HOSTTYPE')
None

If I do the same thing with a different variable (XILINX, in this
case), it works fine.

# echo $XILINX
/Xilinx
# python
>>import os
print os.environ.get('XILINX')
/Xilinx

Any thoughts on why it is behaving this way?

Thanks,
John

Nov 14 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
pa**********@gmail.com wrote:
Hello,

I am trying to retrieve a linux environment variable using
os.environ.get, however it does not appear to be working properly. It
returns none for a variable that does, in fact exist.

# echo $HOSTTYPE
x86_64
# python
>>>import os
print os.environ.get('HOSTTYPE')
None

If I do the same thing with a different variable (XILINX, in this
case), it works fine.

# echo $XILINX
/Xilinx
# python
>>>import os
print os.environ.get('XILINX')
/Xilinx

Any thoughts on why it is behaving this way?
is HOSTTYPE exported? If not, it will not be included in
subprocess-environments by the shell.

Diez
Nov 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.