Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Wed, 05 Nov 2008 13:18:27 +1100, Ben Finney wrote: > > > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > > > > Your example shows only that they're important for grouping the > > expression from surrounding syntax. As I said. > > > > They are *not* important for making the expresison be a generator > > expression in the first place. Parentheses are irrelevant for the > > generator expression syntax. > > Okay, technically correct but parenthesis belong to generator expressions > because they have to be there to separate them from surrounding syntax > with the exception when there are already enclosing parentheses. So > parenthesis are tied to generator expression syntax.
No, I think that's factually wrong *and* confusing. >>> list(i + 7 for i in range(10)) [7, 8, 9, 10, 11, 12, 13, 14, 15, 16] Does this demonstrate that parentheses are “tied to” integer literal syntax? No. Here, parentheses were used because they're part of the function call syntax. In your example, parentheses were used as a grouping operator. In neither case are they “tied to” the generator expression syntax. It's best to be clear what parentheses *are* used for; they don't “create a generator” nor are they “tied to” the generator expression syntax. -- \ “In any great organization it is far, far safer to be wrong | `\ with the majority than to be right alone.” —John Kenneth | _o__) Galbraith, 1989-07-28 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list