Big time WTF with generators - bug?
Paul Rubin
http
Wed Feb 13 03:41:46 EST 2008
James Stroud <jstroud at mbi.ucla.edu> writes:
> I defined a little debugging function called iterprint:
>
> def iterprint(thing): ...
> for x in thing:
> iterprint(x)
of course this mutates the thing that is being printed. Try using
itertools.tee to fork a copy of the iterator and print from that.
I didn't look at the rest of your code enough to spot any errors
but take note of the warnings in the groupby documentation about
pitfalls with using the results some number of times other than
exactly once.
More information about the Python-list
mailing list