[Python-Dev] syntactic support for sets
Raymond Hettinger
raymond.hettinger at verizon.net
Wed Feb 1 20:50:28 CET 2006
[Greg Wilson]
> I have a student who may be interested in adding syntactic support for
> sets to Python, so that:
>
> x = {1, 2, 3, 4, 5}
>
> and:
>
> y = {z for z in x if (z % 2)}
>
> would be legal. There are of course issues (what's the syntax for a
> frozen set? for the empty set?), but before he even starts, I'd like to
> know if this would ever be considered for inclusion into the language.
Generator expressions make syntactic support irrelevant:
x = set(xrange(1,6))
y = set(z for z in x if (z % 2))
y = frozenset(z for z in x if (z % 2))
Accordingly,Guido rejected the braced notation for set comprehensions.
See: http://www.python.org/peps/pep-0218.html
Raymond
More information about the Python-Dev
mailing list