[Python-Dev] PEP 289: Generator Expressions (second draft)

Barry Warsaw barry at python.org
Thu Oct 23 11:04:41 EDT 2003

On Thu, 2003-10-23 at 10:18, Andrew Koenig wrote:
> > Raymond, please take this to c.l.py for feedback!  Wear asbestos. :-)
> One thought:
> If we eventually adopt the notation that {a, b, c} is a set, there is a
> potential ambiguity in expressions such as {x**2 for x in range(n)}.  Which
> is it, a set comprehension or a set with one element that is a generator
> expression?
> It would have to be the former, of course, by analogy with
> [x**2 for x in range(n)], which means that if we introduce generator
> expressions, and we later introduce set literals, we will have to introduce
> set comprehensions at the same time.  Either that or prohibit generator
> expressions as set-literal elements unless parenthesized -- i.e.
> {(x**2 for x in range(n))}.

Heh, and then {(x, x**2) for x in range(n)} is a dict comprehension.

okay-/now/-i'll-shut-up-about-them-ly y'rs,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20031023/31b49715/attachment-0001.bin

More information about the Python-Dev mailing list