Python 3000 idea -- + on iterables -> itertools.chain

Georg Brandl g.brandl-nospam at
Mon Nov 13 09:07:01 CET 2006

George Sakkis wrote:
> Fredrik Lundh wrote:
>> John Reese wrote:
>> > It seems like it would be clear and mostly backwards compatible if the
>> > + operator on any iterables created a new iterable that iterated
>> > throught first its left operand and then its right, in the style of
>> > itertools.chain.
>> you do know that "iterable" is an informal interface, right?  to what
>> class would you add this operation?
>> </F>
> The base object class would be one candidate, similarly to the way
> __nonzero__ is defined to use __len__, or __contains__ to use __iter__.

What has a better chance of success in my eyes is an extension to yield
all items from an iterable without using an explicit for loop: instead of

for item in iterable:
     yield item

you could write

yield from iterable


yield *iterable



More information about the Python-list mailing list