Last Updated: May 22, 2026
A generator expression is a one-line way to build a generator without writing a def block, a yield, or any custom class. You get the same lazy, one-value-at-a-time behavior of a generator, but in a syntax that looks almost identical to a list comprehension. This chapter focuses on the genexp form itself: how to write it, what kind of object it produces, how it streams data through pipelines, and where it's the wrong tool.