Python Generators

Someone had mentioned “generators” in python to me, so I decided to figure out what it was… and I figured it out. I think a simple example would help explain it:

Basically you can iterate over this “generator” which is a special function that “yield”s more than one value if you keep pinging it.

Adding this to the toolkit in my brain. I’m thinking one potential use is taking a resultset from a datastore (e.g. mysql) and converting it into an object.