Generator

John Posner jjposner at snet.net
Sun Mar 22 21:38:02 EDT 2009


[snip]
> > If you want next(g) to yield 3, you'd have to do something like:
> > 
> >     g = (x for x in s[:])
> > 
> > where s[:] makes a copy of s that is then iterated over.
 

BTW, this simpler statement works, too:

   g = iter(s[:])




More information about the Python-list mailing list