def fetch_profiles(api, screen_names=[], ids=[]):
 profiles = []
 (key, lookups) = (['user_ids', ids] if ids else ['screen_names', screen_names])
 for batch_idx in range(ceil((len(lookups) / TWITTER_PROFILE_BATCH_SIZE))):
  offset = (batch_idx * TWITTER_PROFILE_BATCH_SIZE)
  batch = lookups[offset:(offset + TWITTER_PROFILE_BATCH_SIZE)]
  try:
   for user in api.lookup_users(**{key: batch}):
    profiles.append(user._json)
  except tweepy.error.TweepError as e:
   if (e.response.status_code == 404):
    pass
   else:
    raise e
 return profiles

def fetch_profiles ( api , screen_names = [ ] , ids = [ ] ) : profiles = [ ] ( key , lookups ) = ( [ 'user_ids' , ids ] if ids else [ 'screen_names' , screen_names ] ) for batch_idx in range ( ceil ( ( len ( lookups ) / TWITTER_PROFILE_BATCH_SIZE ) ) ) : offset = ( batch_idx * TWITTER_PROFILE_BATCH_SIZE ) batch = lookups [ offset : ( offset + TWITTER_PROFILE_BATCH_SIZE ) ] try : for user in api . lookup_users ( ** { key : batch } ) : profiles . append ( user . _json ) except tweepy . error . TweepError as e : if ( e . response . status_code == 404 ) : pass else : raise e return profiles
a wrapper method around tweepy .