Implementation of generators ala Python