PEP 289: Generator Expressions (please comment)

Rainer Deyke rainerd at eldwood.com
Thu Oct 23 18:15:57 EDT 2003


Raymond Hettinger wrote:
> "Daniel Dittmar" <daniel at dittmar.net> wrote in message
> news:bn9evl$5ug$1 at news.eusc.inter.net...
>> Why should generator comprehension be useful only for arguments?
>
> It is not limited to just function arguments.
> It is a first class citizen.  You can use it for anything you want.

At the very least, it would require parentheses if you want to create a list
containing exactly one such generator.

[(x for x in y)] # List containing generator
[x for x in y]   # List comprehension


-- 
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com






More information about the Python-list mailing list