On Wed, 25 Sep 2013 14:26:23 +0000, John Gordon wrote:
> You could try this:
>
> try:
> referer = os.environ.get('HTTP_REFERER', 'UnknownRef')
> except KeyError:
> referer = None
> if not referer:
> referer = 'UnknownRef'
The get method will not raise KeyError. If the key is missing,
'UnknownRef' will be returned instead.
So when Nikos reports that os.environ.get('HTTP_REFERER', 'UnknownRef')
"doesn't return anything", he is mistaken. It returns 'UnknownRef'.
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list