added python generator code