In python, a function can yield a value, rather than return one (e.g. yield x). This makes it a generator, which is a rather nifty (though frequently unnecessary) kind of iterator (actually, an iterable object). When the "function" is called, rather than executing, it returns a generator-iterator. Whenever the iterator is nexted, function execution resumes where it was left off, with local variables intact, as they were. When a yield statement is executed, the iterator returns the yielded value, and execution is suspended until the next next.