# callback function will print the records as they are read
def print_result((key, metadata, record)):
print(key, metadata, record)
# Execute the scan and call print_result for each result
scan.foreach(print_result)
Also posted on Stack Overflow.