Python programmers use “for” loops all of the time. But how do these loops work? How is it that strings, lists, tuples, dicts, and files all work with loops, but give different values with each iteration? And how can we make our own classes iterable?
This course answers all of these questions, introducing Python’s “iterator protocol” and how you can use it to your benefit. First, we’ll look at how you can add iteration to your own classes. Then we’ll look at generators and generator functions, which allow us to create iterators using function syntax. The course ends with an introduction to generator comprehensions, which produce generators using code that’s similar to a list comprehension.
Monthly
Annual
Save 20%
I’m a one-person company dedicated to improving your career via Python and related technologies. If you haven’t gotten value from any of my courses, then just tell me — and I’ll refund your money.
Reuven is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China — as well as to people around the world, via his online courses.
Reuven created one of the first 100 Web sites in the world just after graduating from MIT’s computer science department. He opened Lerner Consulting in 1995, and has been offering training services since 1996.
In 2020, Reuven published “Python Workout,” a collection of Python exercises with extensive explanations, published by Manning. He’s currently finishing edits on “Pandas Workout,” a similar collection of exercises using the “Pandas” library for data analytics.
Reuven’s free, weekly “Better developers” newsletter, about Python and software engineering, is read by more than 30,000 developers around the globe. His “Trainer weekly” newsletter is popular among people who give corporate training.
Reuven’s most recent venture is Bamboo Weekly: Every Wednesday, he presents a problem based on current events, using a public data set. And every Thursday, he shared detailed solutions to those problems using Pandas.
Reuven’s monthly column appeared in Linux Journal from 1996 until the magazine’s demise in 2019. He was also a panelist on both the Business of Freelancing and Freelancers Show podcasts.
Reuven has a bachelor’s degree in computer science and engineering from MIT, and a PhD in learning sciences from Northwestern University. He lives in Modi’in, Israel with his wife and three children.
I’m a one-person company; ask me questions at reuven@lernerpython.com , and I’ll answer you personally.
I send a full-length Python article to more than 30,000 people each week — on topics ranging from iterators to descriptors, variable assignment to sets, exceptions to command-line arguments. Join me, and get smarter about Python each week!