
Checkpoint
Checkpoint: The Beacon Pipeline
Beacon towers across Pythonia send brightness readings to the Guild. Some towers never stop sending! Pip needs a lazy pipeline that joins the towers, keeps only the bright readings, and stops after a few.
You'll use every tool from this chapter: a generator function,
yield from, a generator expression and islice.
towers = [[3, 9], [12, 1, 8]]
print(first_bright(towers, 5, 2)) # [9, 12]
Assignment
all_readings(towers): a generator that usesyield fromto hand out every reading of every tower, in order.bright(readings, limit): return a generator expression of the readings that are bigger thanlimit.first_bright(towers, limit, n): return a list of the firstnbright readings. Connect the two stages and useislice. It must work even if a tower never stops sending.
all_readings(towers): a generator that usesyield fromto hand out every reading of every tower, in order.bright(readings, limit): return a generator expression of the readings that are bigger thanlimit.first_bright(towers, limit, n): return a list of the firstnbright readings. Connect the two stages and useislice. It must work even if a tower never stops sending.
main.py Python sleeping
Press Run to try your code, then Check to test it.