def list_generator(pages, num_results=50):
    result = []
    page = list(next(pages))
    result += page
    while True:
        if (not pages.continuation_token):
            break
        if (num_results is not None):
            if (num_results == len(result)):
                break
        page = list(next(pages))
        result += page
    return result
def list_generator(pages, num_results=50):
    result = []
    page = list(next(pages))
    result += page
    while True:
        if (not pages.continuation_token):
            break
        if (num_results is not None):
            if (num_results == len(result)):
                break
        page = list(next(pages))
        result += page
    return result