def apply_to_stripe_customers(func, starting_after=None):

    print u"calling apply_to_stripe_customers({func_name}, starting_after={starting_after})".format(
        func_name=func,
        starting_after=starting_after
    )

    # get a page of customers
    resp = stripe.Customer.all(limit=100, starting_after=starting_after)

    # do something with each customer
    for customer in resp.data:
        func(customer)

    # load another page if we're not done yet
    if resp.has_more:
        last_customer_on_page = resp.data[-1]
        apply_to_stripe_customers(func, starting_after=last_customer_on_page.id)
Apply a given function to every one of our Stripe customers in turn.
dataset/ETHPy150Open Impactstory/total-impact-webapp/scripts.py/apply_to_stripe_customers