Partial implementation of Python 2 generator.