[Python-ideas] Use the plus operator to concatenate iterators

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Aug 5 17:04:55 CEST 2015


On 05/08/2015 15:16, Paul Moore wrote:
> On 5 August 2015 at 15:00, Sven R. Kunze <srkunze at mail.de> wrote:
>> 60% of the thread are about the ominous * operator on lists. << Seriously?
>> The thread started with a simple and useful idea; not with some rarely used
>> feature.
>> 35% of the thread are about some internal implementation issues. <<< Maybe
>> not easy but I am certain you will sort that out.
>> 5% about its usefulness and simplicity. <<< I stick to that.
>
> There is no single iterator type that can have a "+" operator defined
> on it. If you pick one or more such types, other (possibly user
> defined) types will not work with "+" and this will confuse users.
>
> itertools.chain is available to do this in an unambiguous and
> straightforward manner, its only downside (for some people) is that
> it's slightly more verbose.
>
> Paul

c = itertools.chain

should be short enough for those people.  I've discarded ch as it's too 
often used as a character, and cn as it's likely to get confused with 
some type of connector.  Me, I'll stick with the readable version.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-ideas mailing list