This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients gregory.p.smith, marystern
Date 2009-02-13.19:21:52
SpamBayes Score 1.3067772e-06
Marked as misclassified No
Message-id <1234552914.58.0.376500342624.issue5253@psf.upfronthosting.co.za>
In-reply-to
Content
>>> os.environ['FOO']
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: 'FOO'
>>> os.environ.get('FOO')
>>> os.environ.get('FOO', 'bar')
'bar'


% export FOO=
% python2.5
>>> import os
>>> os.environ['FOO']
''

An environment variable set to '' is valid and is still considered set
(thats how the environment works).
History
Date User Action Args
2009-02-13 19:21:54gregory.p.smithsetrecipients: + gregory.p.smith, marystern
2009-02-13 19:21:54gregory.p.smithsetmessageid: <1234552914.58.0.376500342624.issue5253@psf.upfronthosting.co.za>
2009-02-13 19:21:53gregory.p.smithlinkissue5253 messages
2009-02-13 19:21:52gregory.p.smithcreate