AI engineering glossary · Python advanced

What is generator?

Generator: A special iterator built by a function that uses yield. It pauses at each yield, remembers its local state, and continues from there on the next request. It produces values lazily, one at a time, saving memory.

Level: intermediateTopic: Python advanced

Generator: an example

def evens(n): for i in range(0, n, 2): yield i produces even numbers on demand without building a list.

Related terms

More Python advanced terms

Where you learn it

Generator is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.