ich bekomme einen SyntaxError beim Ausfuehren eines Scripts, in dem ich einfach keinen Fehler entdecken kann

Die Fehlerausgabe:
Code: Alles auswählen
$$> ./index.py
./index.py: line 24: syntax error near unexpected token `('
./index.py: line 24: `def parse_uri(req):'
Hier nun der Code:
Code: Alles auswählen
if __name__ != '__main__':
from mod_python import apache
from mod_python import util
else:
from sys import argv
HTML = """
<html>
<head>
<title>pYtHoN</title>
</head>
<body bgcolor="#5A3837" text="white">
%s
</body>
</html>
"""
URI_PREFIX = "/~nkoehrin/index.py"
def parse_uri(req):
cmd = req.unparsed_uri.lstrip(URI_PREFIX)
if cmd.strip():
if cmd.startswith('?'):
return dict([x.split('=') for x in cmd.lstrip('?').split('&')])
else:
return cmd
else:
return None
def handler(req):
cmd = parse_uri(req)
content = ""
if cmd:
if type(cmd) == str: content += "COMMAND IS: "+cmd
elif type(cmd) == dict:
content += "FOLLOWING DATA FETCHED:<br />\n"
for key in cmd: content += key+': '+str(cmd[key])
req.send_http_header()
req.write(HTML%content)
return apache.OK
if __name__ == '__main__':
class Req:
def __init__(self):
self.unparsed_uri = URI_PREFIX
if len(argv) > 1: self.unparsed_uri += argv[1]
def send_http_header(self): return 0
def write(self, s):
print s
return 0
class Apache:
def __init__(self):
self.OK = 200
self.NOT_FOUND = 404
global apache
req = Req()
apache = Apache()
handler(req)