intersection and union idea

fleet at fleet at
Tue Jul 24 11:38:06 EDT 2001

"Learning Python, First Edition (1999) page 109.  provides examples.

				- fleet -

>Message: 17
>   Date: Tue, 24 Jul 2001 08:42:27 +0100
>   From: Stephen Horne <steve at>
>Subject: Re: intersection and union idea
>On Mon, 23 Jul 2001 16:57:20 -0700, "Neil Macneale"
><mac4-devnull at> wrote:
>>I was day dreaming about python today, and I realized that it would be
>>very python-ish to have intersection and union operators for lists and
>>tuples. Eg:
>>>>> (1,2,3,4) | (1,3,6,8)
>>>>> (1,2,3,4) & (1,3,6,8)
>You could define your own set object, or an alternative to a
>dictionary or list, using a class and defining the following
>__and__(self, other)
>__or__(self, other)
>Whether it's really useful, though, is a different thing - you're
>probably better off with simple functions operation on the existing
>As a language addition - well, it wouldn't break anything I can see.
>It could have some consiseness value, but it is really syntactic

More information about the Python-list mailing list