............................
Traceback (most recent call last):
File "C:\Python\tabla.py", line 929, in -toplevel-
tablesDirectory = tablesDirectoryPrefix + os.environ['REMOTE_ADDR']
File "C:\Python23\lib\os.py", line 417, in __getitem__
return self.data[key.upper()]
KeyError: 'REMOTE_ADDR'
..........................
Thanks for reading this.
R.
What trouble do you have? AFAICT, The key REMOVE_ADDR wasn't in the
dictionary, meaning that the environment variable doesn't exist.
Cheers,
Frans
The only explanation I can give is that the environment varialbe REMOTE_ADDR
does not exist! Wrap your high-level code with try and except. Example:
try:
tablesDirectory = tablesDirectoryPrefix + os.environ['REMOTE_ADDR']
except KeyError:
# Code to handle the fact tht REMOT_ADDR does not exist.
Hope that this helps and is not just another infamous "Dermot Didn't Get It"
posting!
Cheers!!
-----Original Message-----
From: python-list-bounces+doran_dermot=emc...@python.org
[mailto:python-list-bounces+doran_dermot=emc...@python.org] On Behalf Of
root...@gazeta.pl
Sent: 15 December 2004 13:34
To: pytho...@python.org
Subject: KeyError
Hello.
Maybe someone will help me with this KeyError:
............................
Traceback (most recent call last):
File "C:\Python\tabla.py", line 929, in -toplevel-
tablesDirectory = tablesDirectoryPrefix + os.environ['REMOTE_ADDR']
File "C:\Python23\lib\os.py", line 417, in __getitem__
return self.data[key.upper()]
KeyError: 'REMOTE_ADDR'
..........................
Thanks for reading this.
R.
That tabla.py of yours is certainly to be executed in a CGI environment. So
call it that way - or provide the neccessary environment by stuffing values
to os.environ
--
Regards,
Diez B. Roggisch
... or just replace os.environ['REMOTE_ADDR'] with
os.environ.get('REMOTE_ADDR', 'enter_default_here') to use a default in
case of missing REMOTE_ADDR ...
HtH, Roland
-----Original Message-----
From: python-list-bounces+doran_dermot=emc...@python.org
[mailto:python-list-bounces+doran_dermot=emc...@python.org] On Behalf Of
HtH, Roland
--
http://mail.python.org/mailman/listinfo/python-list