I am trying to run a basic random sentence generator to test my web server for python... all it does is open 3 files and randomly pick a line from each.
It does run fine on my laptop but on the web server it fails and generates a syntax error for one part of the code (a part I got from another stack overflow question here - How to get line count cheaply in Python? ).
The error is:
File "sentence.py", line 17
with open(fname) as f:
SyntaxError: invalid syntax
And the part with the error is:
def file_len(fname):
with open(fname) as f:
for i, l in enumerate(f):
pass
return i + 1
The server is using Python 2.4.3
Does anyone see an immediate problem here?