Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Provider Logo

Learning Python Generators

via LinkedIn Learning


Python generators are the best way to iterate through large and complex data sets. Find out how to use generators in your own code, in these Python tutorials.

Generators are a concept unique to Python. They're incredibly helpful if you know how and when to use them. Simply put, generators are the best way to iterate through large and complex data sets. Pythonista Josh McQuiston explains everything you need to know about Python generators, providing examples of generators in action. Learn how to build a basic generator function, use generator expressions and objects, and see how generators work behind the scenes to power context managers and coroutines.


  • Welcome
  • What you should know
  • Using the exercise files
1. Generator Functions and Expressions
  • Generators overview
  • Build a generator function
  • Use a generator expression
  • Use a generator object
  • Challenge: Fibonacci sequence generator
  • Solution: Fibonacci sequence fenerator
  • Build a generator pipeline
2. Using Generators as Context Managers
  • Context managers overview
  • Build a context manager using yield
  • The @contextmanager decorator
  • Use the yielded value
3. Coroutines
  • Coroutine overview
  • Create a coroutine
  • Build a @coroutine decorator
  • Consume values with the send method
  • Coroutine pipelines
  • Next steps

Taught by

Josh McQuiston

Related Courses


0.0 rating, based on 0 reviews

Start your review of Learning Python Generators

Never stop learning Never Stop Learning!

Get personalized course recommendations, track subjects and courses with reminders, and more.

Sign up for free