[Python-Dev] syntactic support for sets
Brett Cannon
brett at python.org
Wed Feb 1 20:59:10 CET 2006
On 2/1/06, Greg Wilson <gvwilson at cs.utoronto.ca> wrote:
> Hi,
>
> 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.
I am -0 on set syntax support. If the set() constructor was expanded
to take an arbitrary number of arguments (and thus be more inline with
the dict constructor) then the syntax need really starts to go away
since the above could be done as ``set(1, 2, 3, 4, 5)``.
As for the set copmrehension/expression/thing, I don't think that is
needed at all when ``set(z for z in x if z % 2)`` will get the job
done just as well without adding more syntactic sugar to the language
for something that is so easy to do already.
> p.s. please Cc: me as well as the list, since I'm no longer subscribed.
-Brett
More information about the Python-Dev
mailing list