[Python-ideas] pipe function for itertools?

Carl Johnson cmjohnson.mailinglist at gmail.com
Wed May 27 09:15:13 CEST 2009

I was one of the commenters who said you should put the idea here. I
end up using generators in a pipe-like fashion quite a bit, so a pipe
[iter, func]tool would be useful. I also liked the head function
listed on the page, because when using the interactive interpreter I
often want to see just a part of a larger output without having to go
to all the trouble of whipping up something using islice or izip +
irange. I think we could also use a tail function, and although
obviously it wouldn't work with itertools.count it is useful when
you're filtering a large file, and you just want to see the last part
of the output to tell if your filters are basically doing the right

Of course, all of these functions are somewhat trivial, but it could
save a little work for a lot of people if they were in the stdlib.
Also, they could be made to work like the proposed "yield from" and
pass through .send and .raise commands, etc., which actually is a fair
amount of work to implement.

-- Carl Johnson

More information about the Python-ideas mailing list