Syntax error when using "with open" in Python (python newbie)
- by Tony
[root@234571-app2 git]# ./test.py
File "./test.py", line 4
with open("/home/git/post-receive-email.log",'a') as log_file:
^
SyntaxError: invalid syntax
The code looks like this:
[root@234571-app2 git]# more test.py
#!/usr/bin/python
from __future__ import with_statement
with open("/home/git/post-receive-email.log",'a') as log_file:
log_file.write("hello world")
and I am using Python 2.5.5
[root@234571-app2 git]# python -V
Python 2.5.5