PEP 289: Generator Expressions (please comment)

Bjorn Pettersen bjorn.pettersen at comcast.net
Sat Oct 25 17:47:59 EDT 2003


imcmeans at telus.net (Ian McMeans) wrote in
news:7f9e1817.0310251040.7301d172 at posting.google.com: 

> I really like this. Not only is it less of a special case (than using
> []), but it makes it easy to use comprehensions for other data types.
> I think that using the yield keyword makes it more obviously a
> generator.
> 
> sum(x for x in lst) makes it clear what it will compute, but not that
> it will be computed using a generator. sum(yield x for x in lst) makes
> it more apparent that you're creating a generator and passing it to
> sum.

I can't think of a situation where that would be something I wanted to 
know, ie. that would change the way I programmed. Do you have an example?

If not, adding words wihtout a practical purpose just seems... Cobol'ish 
<wink>.

-- bjorn




More information about the Python-list mailing list