environment variable issue
Michel Leunen
michel at nospam.please
Mon Sep 15 14:43:05 EDT 2008
Hi,
Could someone explain me what I'm doing wrong here? I'm trying to
retrieve the value of an environment variable in Ubuntu 8.04 like this:
>>> import os
>>> os.environ['USER']
'michel'
This works but this doesn't:
>>> os.environ['HOSTNAME']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'HOSTNAME'
Why is it working in the first case but not in the second one. I must be
missing something but it seems I'm not able to figure it out.
Thanks,
Michel
--
Michel Leunen
http://linux.leunen.com
More information about the Python-list
mailing list