[Python-Dev] Iterator addition?
Sami Hangaslammi
shang@cc.jyu.fi
Mon, 30 Jul 2001 12:20:54 +0300 (EET DST)
Just van Rossum wrote:
> from __future__ import generators
>
> def concat(*iterators):
> for i in iterators:
> for x in i:
> yield x
>
> for x in concat(iter1, iter2):
> do_something(x)
Yes, this is the solution that I eventually ended up with too. However,
the real point I was trying to raise was, wether interators should look
like sequences regarding addition, since the two are already exchangeable
in so many places (e.g. tuple unpacking).
Moshe Zadka wrote:
> Wasn't there talk about having an iterator module with useful stuff
> like that?
This would be a great idea. I've ended up with a sizeable bunch of small
utility functions when playing around with generators/iterators in 2.2a1.
-- Sami Hangaslammi --