[Python-Dev] itertools.chain should take an iterable ?

Paolino paolo_veronelli at libero.it
Fri Sep 2 20:15:55 CEST 2005

Christos Georgiou wrote:
> "Paolino" <paolo_veronelli at libero.it> wrote in message 
> news:431842AA.2050405 at libero.it...
>>What if I want to chain an infinite list of iterables?
>>Shouldn't itertools.chain be built to  handle that?
> Raymond already suggested a four-line function that does exactly that.
> Create your own personal-library modules containing the functions you find 
> useful as building blocks, and when you have a large sw base using them, 
> present your building blocks along with their use cases as arguments for 
> inclusion in the standard library.
>>I don't think it is a problem to accept only the second case you paste
>>and produce TypeError on the others.
> It would break compatibility with the current uses of itertools.chain .  I 
> like it (and have used it) as it is. 

I see ,I just thought itertools was young and important enough to be 
investigated and eventually changed, but probably this is not the place 
to talk about that.I will submit the feature request to SF.

I must add that the inverse story would have been

def handy_chain(*args):
   return itertools.chain(iter(args))

a two-line function (ex lambda).

Generally speaking, having a star-signature in a base library function 
is not a good choice. This is a proof of a case.

Thanks all and have a nice summer.

More information about the Python-Dev mailing list