Some set operators

Fredrik Lundh fredrik at pythonware.com
Sat Oct 15 17:06:14 EDT 2005


bearophileHUGS at lycos.com wrote:

> Sometimes I suggest to add things to the language (like adding some set
> methods to dicts), but I've seen that I tend to forget the meaning of
> six set/frozenset operators:
>
> s & t  s &= t
> s | t  s |= t
> s ^ t  s ^= t
>
> My suggestion is to remove them, and keep them only as explicit
> non-operator versions (.symmetric_difference(), .update(),
> .intersection_update(), etc). But maybe now it's too much late to
> remove them... Maybe someone gentle can explain me the advantage
> of having/keeping them.

&, |, and ^ are Python's standard operators for AND, OR, and XOR.  they
make as much sense for sets as they do for bitpatterns...

</F>






More information about the Python-list mailing list