Created
January 8, 2010 08:39
-
-
Save dziegler/271926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import twitter | |
import sys | |
import os | |
from getpass import getpass | |
def looping_call(fun): | |
page = 1 | |
while True: | |
results_page = fun(page=page) | |
for result in results_page: | |
yield result | |
if len(results_page) < 100: | |
break | |
page += 1 | |
def call_api(username,password): | |
api = twitter.Api(username,password) | |
friends = looping_call(api.GetFriends) | |
followers = list(looping_call(api.GetFollowers)) | |
heathens = filter(lambda x: x not in followers,friends) | |
print "There are %i people you follow who do not follow you:" % len(heathens) | |
for heathen in heathens: | |
print heathen.screen_name | |
if __name__ == "__main__": | |
password = getpass() | |
call_api(sys.argv[1], password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also simply get the difference of the two sets and avoid the lambda function, I think the following code would work: