subtle side effect of generator/generator expression

bonono at gmail.com bonono at gmail.com
Sun Oct 16 11:51:59 EDT 2005


thanks. I was looking for scanl in itertools but can't find it so I
implement my own then run into some subtle bugs which first made me
think my scanl is the problem. Then notice my wrong perception about
generator(and iterable in general, though the built-in iterables like
list, dict don't seem to have this characteristic).

Simon Percivall wrote:
> If you find that you want to iterate over an iterable multiple times,
> have a look at the solution that the tee() function in the itertools
> module provides (http://docs.python.org/lib/itertools-functions.html).
> (Have a look at the rest of the itertools module as well, for that
> matter.)




More information about the Python-list mailing list