[Python-ideas] generator.__add__

cool-RR cool-rr at cool-rr.com
Sun Apr 4 19:34:15 CEST 2010


On Sun, Apr 4, 2010 at 7:20 PM, Masklinn <masklinn at masklinn.net> wrote:

> On 4 Apr 2010, at 18:58 , cool-RR wrote:
> >
> > I'm still a bit confused by generators and generator expressions, but
> what
> > about making a `generator.__add__` method, that'll act like
> > `itertools.chain`?
>


> What would the use case be,


I'm not sure I understand your question. The same use case as for
`itertools,chain`: When you have several generators you want to iterate
over, one after another. (True, it might be not as good when you have more
than 2.)


> and why couldn't you use itertools.chain or
> generator.send for that?
>

I could use `itertools.chain`, but why type so much? I think if you have two
generators, g1 and g2, then it makes sense that g1 + g2 will be an iterator
that goes over the elements of both of them.

About `generator.send`, I don't understand how it's related. But I'm still
new to this.

Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100404/1b91104f/attachment.html>


More information about the Python-ideas mailing list