George Sakkis wrote:
> On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> 
>> BTW, I keep using the idiom itertools.chain(*iterable).  I guess that
>> during function calls *iterable gets expanded to a tuple.  Wouldn't it
>> be nice to have an equivalent one-argument function that takes an
>> iterable of iterables and return the 'flattened' iterable?
> 
> Indeed; I don't have any exact numbers but I roughly use this idiom as
> often or more as the case where chain() takes a known fixed number of
> arguments. The equivalent function you describe is trivial:
> 
> def chain2(iter_of_iters):
>   for iterable in iter_of_iters:
>      for i in iterable:
>         yield i

or fwiw

chainstar = lambda iters : (x for it in iters for x in it)

- a form that better suggests how to inline it in the calling expression, if 
applicable.

Cheers, BB

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to