PEP-0218 (Was: RE: Sets in Python)

Mikael Olofsson mikael at
Fri Feb 2 11:50:57 CET 2001

Tim, Greg and others,

On 31-Jan-01 Tim Peters wrote:
 >  Note Greg Wilson's PEP for adding a set type to Python:

This looks promising. I am especially glad to see that the PEP proposes
the logical operations '|', '&', and '^' to implement union, intersection 
and symmetric difference. However, I'm not sure I like the proposed use
of '-' for difference. Mathematician use '\' (so called setminus). That 
would have been my favourite, but we use '\' for so many things, and 
especially not as an arithmetic operation. The visually closest thing 
would be '/', which is what I have used myself. That would for instance 
make it possible to let -S mean {-x for x in S}.

Let's just hope that there will be a UserSet class that I can subclass, 
for instance to implement direct sums as A+B and direct difference as
A-B (interpreted as A+(-B) with -B as above), provided that '-' is not
used for difference. I could also implement cartesian products as A*B. 
Someone else could perhaps think of a resonable way to interprete the 
modulo operator (%) in terms of sets...

It sure does look promising.

programming-is-doing-math-ly y'rs


E-Mail:  Mikael Olofsson <mikael at>
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    02-Feb-01
Time:    11:18:01

         \ /     ASCII Ribbon Campaign
          X      Against HTML Mail
         / \

This message was sent by XF-Mail.

More information about the Python-list mailing list