def mygenerator(): for i in range(10): yield i for j in mygenerator(): print j