[Python-ideas] Generators' and iterators' __add__ method

Yuval Greenfield ubershmekel at gmail.com
Wed Feb 15 17:20:41 CET 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120215/b10eebbb/attachment.html>


More information about the Python-ideas mailing list