@contextmanager
def stripe_temporary_api_key(temp_key):
    import stripe
    backup_key = stripe.api_key
    stripe.api_key = temp_key
    yield
    stripe.api_key = backup_key
A contextmanager
dataset/ETHPy150Open pydanny/dj-stripe/djstripe/stripe_objects.py/stripe_temporary_api_key