1) It always sucks when moving from lists to iterators.
2) As you showed, transition to Python 3 is made easier.

Thus: +1 for me

On 05.08.2015 02:22, Grayson, Samuel Andrew wrote:
Concatenation is the most fundamental operation that can be done on iterators. In fact, we already do that with lists.

    [1, 2, 3] + [4, 5, 6]
    # evaluates to [1, 2, 3, 4, 5, 6]

I propose:

    iter([1, 2, 3]) + iter([4, 5, 6])
    # evaluates to something like itertools.chain(iter([1, 2, 3]), iter([4, 5, 6]))
    # equivalent to iter([1, 2, 3, 4, 5, 6])

There is some python2 code where:

    a = dict(zip('abcd', range(4)))
    isinstance(a.values(), list)
    alphabet = a.keys() + a.values()

In python2, this `alphabet` becomes a list of all values and keys

In current python3, this raises:

    TypeError: unsupported operand type(s) for +: 'dict_keys' and 'dict_values'

But in my proposal, it works just fine. `alphabet` becomes an iterator over all values and keys (similar to the python2 case).

Sincerely,
Sam G


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/