note
not using import
in Python, I prefer the external generator style

I'm using the term "external generator" the way
http://journal.stuffwithstuff.com/2013/01/13/iteration-inside-and-out/
does. The internal generator you've got is fine, I just think
this way is more clear and flexible. (I think the way the
boolean parameter in the original is confusing.)