PEP-0218 (Was: RE: Sets in Python)
Mikael Olofsson
mikael at isy.liu.se
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:
>
> http://python.sourceforge.net/peps/pep-0218.html
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.
I've-said-this-before-
programming-is-doing-math-ly y'rs
/Mikael
-----------------------------------------------------------------------
E-Mail: Mikael Olofsson <mikael at isy.liu.se>
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
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