I found this very nice tutorial on what Python generators are and how they can be used:


I had a difficult time with the other tutorials out there because, funnily enough, they seem to assume that you already know what generators are before they try to teach you about it (???).

They key concept this tutorial taught me was that a function with the "yield" keyword in it is NOT the generator per se, but rather that it RETURNS one. Other tutorials seem to miss emphasizing this very important point.

Thanks for the info, there is always room for one more good example to learn from!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.