471,354 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Problem using os.environ.get

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
1 9581
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.

Similar topics

9 posts views Thread by boris.smirnov | last post: by
7 posts views Thread by Joe P. Cool | last post: by
4 posts views Thread by Stephen Cattaneo | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.