On Fri, Oct 21, 2011 at 12:46 PM, Yingjie Lan <lany...@yahoo.com> wrote: > > Thanks a lot to all who answered my question. > I am still not sure why should we enforce that > a generator can not be reused after an explicit > request to revive it?
Here's an example of an explicit request to revive the generator: >>> g = (x*x for x in range(3)) >>> for x in g: print x 0 1 4 >>> g = (x*x for x in range(3)) # revive the generator >>> for x in g: print x #now this will work 0 1 4 ChrisA -- http://mail.python.org/mailman/listinfo/python-list