On 2013-09-25 15:07, Νίκος wrote:
Στις 25/9/2013 5:01 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:
On Wed, Sep 25, 2013 at 2:45 PM, Νίκος <nikos.gr...@gmail.com> wrote:
Hello, i decided am ong other os.environ variables to also grab the
'HTTP_REFERER' fiel but when i try to run my script i was seeing a KeyError
complaining that 'HTTP_REFERER' didnt exist.

So, to see what existed in the os.environ dictionary i issues a print(
os.environ ) to see all available keys and their values:

The Referer header is not mandatory by any means.  Your client
probably does not send it.

But one other problem appeared too:

ni...@superhost.gr [~/www/cgi-bin]# python metrites.py
   File "metrites.py", line 27
     host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or 'UnKnown 
Host'
        ^
SyntaxError: invalid syntax


i dont see anything wrong with that line, and the carret is actually pointing to
the "host".

As has been explained to you before, SyntaxErrors just point to the place where the parser saw something unexpected, not the exact point where you made the error. It is not omniscient. If you don't see the problem on the reported line, you have probably left off a closing bracket or something similar in a previous line. Look back a few lines.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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

Reply via email to