Python Help

Code junkies hangout here

Moderators: ChriThor, LXF moderators

Postby Bazza » Sun Dec 04, 2011 2:24 pm

Not really studied the code except to say......

Check all of your single quotes as they look wrong they should be

Code: Select all
"characters" or 'characters'

Bazza, G0LCU...

Team AMIGA...

The less that I speak, the smarter I sound.
User avatar
LXF regular
Posts: 1596
Joined: Sat Mar 21, 2009 11:16 am
Location: Loughborough

Postby evilnick » Sat Jan 07, 2012 11:23 pm

The underscore characters you are using (I think just for effect) are unicode. You either need to define a unicode encoding at the top of the file or change them for something else like '-'. All the quotes look wrong, as has been mentioned.
also the if __name__ = '__main__' bit is the main executable code in the file, so it shouldn't be indented like that, you have it as part of the main() function, but actually it is the bit that invokes the main() function:
Code: Select all
from django.utils.encoding import smart_str, smart_unicode
import twitter

CusKey = "XX"
CusSec = "XXX"
AccTokKey = "XXXX"
AccTokKeySec = "XXXXX"

def main():
   api = twitter.Api(consumer_key = CusKey, consumer_secret = CusSec, access_token_key = AccTokKey, access_token_secret = AccTokKeySec)
   timeline = api.GetFriendsTimeline()
   for status in timeline:
        print'ascii', 'ignore'), '----', status.text.encode('ascii', 'ignore')
if __name__ == '__main__':
User avatar
Posts: 151
Joined: Mon Apr 04, 2005 11:47 am
Location: LXF towers


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest