A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039375.html below:

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

[Python-Dev] PEP 289: Generator Expressions (second draft)Guido van Rossum guido at python.org
Thu Oct 23 11:03:35 EDT 2003
> 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))}.

Don't worry.  The current proposal *always* requires parentheses
around generator expressions (but it may be the only argument to a
function), so your example would be illegal.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4