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

Paul Moore p.f.moore at gmail.com
Wed Aug 5 18:43:07 CEST 2015


On 5 August 2015 at 15:34, Andrew Barnert <abarnert at yahoo.com> wrote:
> On Aug 5, 2015, at 07:26, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>>> On 5 August 2015 at 15:15, Ed Kellett <edk141 at gmail.com> wrote:
>>> That said, there are solutions, and as far as I can tell it's the only
>>> problem that's been raised in the thread.
>>
>> Are there solutions? No-one has come up with one, to my knowledge.
>>
>> You need to cover
>>
>> 1. All of the many internal iterator types in Python:
>>
>>>>> type(iter([]))
>> <class 'list_iterator'>
>>>>> type({}.keys())
>> <class 'dict_keys'>
>>>>> type({}.values())
>> <class 'dict_values'>
>>>>> type({}.items())
>> <class 'dict_items'>
>
> These last three are not iterators, they're views. The fact that the OP and at least one person explaining the problem both seem to think otherwise implies that the problem is even bigger: we'd need to add the operator to not just all possible iterator types, but all possible iterable types. That's an even more insurmountable task--especially since many iterable types already have a perfectly good meaning for the + operator.

I understand that - that was really my point, that befor anyone can
claim that "there are solutions" they need to be sure they understand
what the problem is - and part of that is getting people to be clear
on what they mean when they say "iterators" - as you say, iterator vs
iterable is a big problem here (and the OP specifically wanted this
for views, *not* iterators...)

Sorry for not being clear that I was explaining that other people
weren't being clear :-)

Paul


More information about the Python-ideas mailing list