R. David Murray added the comment:
Hmm. OK, I didn't think that's how we'd defined those terms, but then I don't
actually work with the parser much myself :) However, generator expressions
are clearly called out as a separate thing. All of the other display types get
Andrés Delfino added the comment:
The documentation says a display may or may not have a comprehension :/
[1, 2, 3] is a list display too.
[x for x in range(3)] is a display that has a comprehension. Acoording to the
doc.
--
R. David Murray added the comment:
That's a generator expression, just like [x for x in ramge(3)] is a list
comprehension, not a list display. And yes, in a number of circumstances
parenthesis are required to delimit the tuple display and disambiguate the
syntax.
Andrés Delfino added the comment:
Ignore the previous comment.
The thing is that "tuple displays" like:
nums = (n for n in range(10))
Yield a generator expression instead of a tuple.
Also, unparenthesized "tuple displays" like 1, 2, 3 can't be used in
expressions,
Andrés Delfino added the comment:
The thing is that "tuple displays" like:
nums = (n for n in range(10))
Yield a generator expression instead of a tuple.
Also, unparenthesized "tuple displays" like 1, 2, 3 can't be used in
expressions, AFAIK:
>>> if 3 == 1, 2, 3:
Cheryl Sabella added the comment:
Actually, 'tuple display' is in the index under 'display' and links to the last
paragraph in 6.2.3. However, except for the index name, that paragraph doesn't
use the phrase 'tuple display'. So it gives the definition without saying what
R. David Murray added the comment:
Nope, a tuple display is not equal to a parenthesized list. For example, in:
x = 1, 2, 3
1, 2, 3 is a tuple display. The parenthesis are optional in that case (in the
general case it is the comma that makes the tuple, not the