def wait_for_operation(compute, project, zone, operation):
    sys.stdout.write('Waiting for operation to finish')
    while True:
        result = compute.zoneOperations().get(
            project=project,
            zone=zone,
            operation=operation).execute()

        if result['status'] == 'DONE':
            print("done.")
            if result in 'error':
                raise Exception(result['error'])
            return result
        else:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1)
# [END wait_for_operation]


# [START run]
dataset/ETHPy150Open googlearchive/compute-getting-started-python/main.py/wait_for_operation/swapped operands of `in`