> For the complete documentation index, see [llms.txt](https://stephanosterburg.gitbook.io/scrapbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stephanosterburg.gitbook.io/scrapbook/coding/python/generator-expression.md).

# Generator Expression

```
genexpr = (expression for item in collection) 
```

The above generator expression “template” corresponds to the following generator function:&#x20;

```
def generator(): 
    for item in collection: 
        yield expression
```

Bader, Dan. Python Tricks: A Buffet of Awesome Python Features (p. 244).&#x20;
