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. -Miles -- http://mail.python.org/mailman/listinfo/python-list