Py2.3: Feedback on Sets

Carl Banks imbosol at aerojockey.com
Sun Aug 17 23:20:27 EDT 2003


Beni Cherniavsky wrote:
> In comp.lang.python, you wrote:
>>I've gotten lots of feedback on the itertools module
>>but have not heard a peep about the new sets module.
>>
>>* Are you overjoyed/outraged by the choice of | and &
>>   as set operators (instead of + and *)?
>>
> ``&`` and ``|`` are good.  In math too, the union/intersection operators are
> very similar to the or/and opearators.  The later are overloaded as
> addition/mulitplication in boolead algebra only because the or/and operators
> are so similar and inconvenient.  This overloading is quite misguided because
> these operators don't define a field or even a ring (xor/and would do that).


Well, if overloading + and * to represent a non-field or non-ring is
misguided, then + and * for lists and strings is also misguided, since
they don't define a field or ring either.

Having said that, it does feel wrong to use "+" for sets to me.  For
container types, I want len(s)+len(t) == len(s+t), but this would not
hold for sets.  That is why I slightly favor & and |.


-- 
CARL BANKS                   http://www.aerojockey.com/software
"You don't run Microsoft Windows.  Microsoft Windows runs you."




More information about the Python-list mailing list