On 9/25/13 10:26 AM, John Gordon wrote:
You could try this:

     try:
         referer = os.environ.get('HTTP_REFERER', 'UnknownRef')
     except KeyError:
         referer = None

     if not referer:
         referer = 'UnknownRef'
There's no need for the "except KeyError" clause. dict.get never raises KeyError, this code will assign 'UnknownRef' in the case the environment variable is missing.

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to