Problem using os.environ.get

Diez B. Roggisch deets at nospam.web.de
Wed Nov 14 11:21:26 EST 2007


 paragon.john at 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



More information about the Python-list mailing list