Generator

John Posner jjposner at snet.net
Mon Mar 23 02:38:02 CET 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