[Python-ideas] Generators' and iterators' __add__ method
Guido van Rossum
guido at python.org
Wed Feb 15 17:41:04 CET 2012
It's been proposed many times, but always stumbled on the fact that
the iterator protocol doesn't have a standard implementation -- each
object implementing __next__ would have to be modified separately to
also support __add__.
On Wed, Feb 15, 2012 at 8:20 AM, Yuval Greenfield <ubershmekel at gmail.com> wrote:
> Wouldn't it be nice to add generators and iterators like we can do with
> lists?
>
> def f():
> yield 1
> yield 2
> yield 3
>
> def g():
> yield 4
> yield 5
>
> # today
> for item in itertools.chain(f(), g()):
> print(item)
>
> # proposal
> for item in f() + g():
> print(item)
>
>
> What do you guys think?
>
> Yuval Greenfield
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list