A generator that returns users for supplied user ids, screen_names,
        or an iterator of user_ids of either. Use the id_type to indicate
        which you are supplying (user_id or screen_name)

def user_lookup(self, ids, id_type="user_id"):
        """
        A generator that returns users for supplied user ids, screen_names,
        or an iterator of user_ids of either. Use the id_type to indicate
        which you are supplying (user_id or screen_name)
        """

        if id_type not in ['user_id', 'screen_name']:
            raise RuntimeError("id_type must be user_id or screen_name")

        if not isinstance(ids, types.GeneratorType):
            ids = iter(ids)

        # TODO: this is similar to hydrate, maybe they could share code?

        lookup_ids = []

        def do_lookup():
            ids_str = ",".join(lookup_ids)
            log.info("looking up users %s", ids_str)
            url = 'https://api.twitter.com/1.1/users/lookup.json'
            params = {id_type: ids_str}
            try:
                resp = self.get(url, params=params, allow_404=True)
            except requests.exceptions.HTTPError as e:
                if e.response.status_code == 404:
                    log.warning("no users matching %s", ids_str)
                raise e
            return resp.json()

        for id in ids:
            lookup_ids.append(id.strip())
            if len(lookup_ids) == 100:
                for u in do_lookup():
                    yield u
                lookup_ids = []

        if len(lookup_ids) > 0:
            for u in do_lookup():
                yield u