[Python-Dev] syntactic support for sets

Josiah Carlson jcarlson at uci.edu
Fri Feb 3 18:00:56 CET 2006

Donovan Baarda <abo at minkirri.apana.org.au> wrote:
> On Wed, 2006-02-01 at 13:55 -0500, Greg Wilson 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)}
> Personally I'd like this. currently the "set(...)"  syntax makes sets
> feel tacked on compared to tuples, lists, dicts, and strings which have
> nice built in syntax support. Many people don't realise they are there
> because of this.

Sets are tacked on.  That's why you need to use 'import sets' to get to
them, in a similar fashion that you need to use 'import array' to get
access to C-like arrays.

People don't realize that sets are there because they tend to not read
the "what's new in Python X.Y", and also fail to read through the
"global module index" every once and a while.

I personally object to making syntax for sets for the same reasons I
object to making arrays, heapqs, Queues, deques, or any of the other
data structure-defining modules in the standard library into syntax.

 - Josiah

More information about the Python-Dev mailing list