Python 3000 idea -- + on iterables -> itertools.chain
g.brandl-nospam at gmx.net
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?
> 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:
you could write
yield from iterable
More information about the Python-list