>>> def gen(): yield 1; yield 2; yield 3 ... >>> g = gen() >>> for el in g: print el ... 1 2 3 >>> for el in g: print el ... >>>