def pascals_triangle(): row = [1] while True: yield row row = map(sum, zip([0] + row, row + [0]))