Код: Выделить всё
Traceback (most recent call last):
File "", line 1, in
File "tweet.py", line 26
print "Favorited: %s" % (result['text'])
^
SyntaxError: invalid syntax
Обновите, я использую следующую версию Python:
Код: Выделить всё
Python 2.7.5 |Anaconda 1.6.1 (x86_64)| (default, Jun 28 2013, 22:20:13)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Код: Выделить всё
def fetch_tweet(tweet):
try:
result = t.favorites.create(_id=tweet['id'])
print "Favorited: %s" % (result['text'])
return result
# when you have already favourited a tweet, this error is thrown
except TwitterHTTPError as e:
print "Error: ", e
return None
Оказывается, мой интерпретатор Python действительно ненавидел часть кода, который у меня был вверху, который каким-то образом мешал печати — я удалил из __future__ import print_function из верхней части файла, и все стало работать гладко.