Generators

Generators are a Python core language construct that allow a function's return value to behave as an iterator. A generator can allow more efficient memory usage by allocating and deallocating memory during the context of a large number of iterations. Generators are defined in PEP255 and included in the language as of Python 2.2 in 2001.

Python generator resources

What's next after you've learned about generators?

What are list, dictionary and set comprehensions?

Show me a list of the best Python learning resources.

What editor should I use to code my Python app?

Sign up here to receive a monthly email with major updates to this site, tutorials and discount codes for Python books.