[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
Код выглядит следующим образом:
[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")
и я использую Python 2.5.5
[root@234571-app2 git]# python -V
Python 2.5.5
/usr/bin/python -V
? - person Will McCutchen   schedule 21.04.2010/usr/local/bin/python
— это 2.5.5, но вы вызываете свой скрипт с/usr/bin/python
, что равно 2.4.3. Попробуйте заменить строку shell shebang на эту:#!/usr/bin/env python
. - person Tamás   schedule 21.04.2010