Skip to content

Instantly share code, notes, and snippets.

@dziegler
Created January 8, 2010 08:39
Show Gist options
  • Save dziegler/271926 to your computer and use it in GitHub Desktop.
Save dziegler/271926 to your computer and use it in GitHub Desktop.
#!/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)
@davej
Copy link

davej commented May 12, 2010

You could also simply get the difference of the two sets and avoid the lambda function, I think the following code would work:

friends = looping_call(api.GetFriends)
followers = looping_call(api.GetFollowers)
heathens = list(set(friends).difference(set(followers)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment