What can you do with generator expressions? In two words: lazy pre-processing.
We basically take the logic that's in a
for loop and move some of it before the
This allows us to chunk up our looping logic, which can sometimes make our code a little bit more readable.
We have a tab delimited file here (
expenses.tsv) that represents prices of various items:
This is a premium screencast available only to active Python Morsels subscribers.
Feel free to watch some of the free screencasts in the Generator Expressions series.
Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.