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

Miles semanticist at
Thu Nov 6 00:07:14 CET 2008

Ben Finney wrote:
> Falcolas writes:
>> Using the surrounding parentheses creates a generator object
> No. Using the generator expression syntax creates a generator object.
> Parentheses are irrelevant to whether the expression is a generator
> expression. The parentheses merely group the expression from
> surrounding syntax.

As others have pointed out, the parentheses are part of the generator
syntax.  If not for the parentheses, a list comprehension would be
indistinguishable from a list literal with a single element, a
generator object.  It's also worth remembering that list
comprehensions are distinct from generator expressions and don't
require the creation of a generator object.


More information about the Python-list mailing list