Is there a better/simpler way to filter blank lines?

Duncan Booth duncan.booth at invalid.invalid
Wed Nov 5 17:05:27 EST 2008


Arnaud Delobelle wrote:

> Lie <Lie.1296 at gmail.com> writes:
>> What makes a generator expression is "<exp> for <var-or-tuple> in
>> <exp>".
>>
>> Parenthesis is generally required because without it, it's almost
>> impossible to differentiate it with the surrounding. But it is not
>> part of the formally required syntax.
>
> ... But *every* generator expression is surrounded by parentheses, isn't
> it?
>
Indeed, the syntax production is:

generator_expression ::= "(" expression genexpr_for ")" 

albeit with the note: "The parentheses can be omitted on calls with only
one argument. See section 5.3.4 for the detail."  but that only means
you don't need a second set of parentheses. A generator expression is
always enclosed in parentheses, the same is NOT true of a tuple.





More information about the Python-list mailing list