A lot of requests now return page-tokens and I was curious what the most appropriate way of dealing with them was?
I have usually just gone with recursion:
def get_followers(user_id,
                  access_token,
                  cursor=''):
    url = 'https://api.instagram.com/v1/users/%s/followed-by?access_token=%s&cursor=%s' % (my_user,
                                                                                           access_token,
                                                                                           cursor)
    print(url)
    response = requests.get(url)
    json_out = json.loads(response.text)
    for user in json_out['data']:
        usrname = user['username']
        my_followers.add_follower(usrname)
        print("Added: %s" % usrname)
    try:
        cursor = json_out['pagination']['next_url']
        get_followers(user_id, access_token, cursor)
    except KeyError:
        print("Finished with %d followers" % len(my_followers.followers))
    return
However, perhaps a:
while True:
  ..
  if condition:
    break
Or some other implementation is seen as more efficient/pythonic?
 
    