Generator Functions

Generator functions look like regular functions but they have one or more yield statements within them. Unlike regular functions, the code within a generator function isn't run when you call it! Calling a generator function returns a generator object, which is a lazy iterable.

6 articles · 25 min read
5 screencasts · 16 min watch

Continue exploring

Profile picture of Trey

Learn something new about Python

My name is Trey Hunner. I publish new Python articles and screencasts through Python Morsels. If you want to keep learning new things about Python, join Python Morsels!

Join Python Morsels ✨