[Python-ideas] Non-boolean return from __contains__

Guido van Rossum guido at python.org
Tue Jul 27 16:02:27 CEST 2010

On Mon, Jul 26, 2010 at 11:33 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Guido van Rossum wrote:
>> The other odd ducks are 'and' and 'or',
> Well, I tried to do something about that with the Overloaded
> Boolean Operators proposal, but it seems to have met with
> a not-very-enthusiastic response.
> Have you had any more thoughts about it? Do you think it's
> a problem worth solving, or are '&' and '|' good enough?
> Or would you rather see some completely different mechanism
> introduced for getting parse trees from expressions, a la

I think that the approach of overloading tons of operators will always
cause a somewhat cramped style, even if we fix some individual
operators. There just are too many things that can go wrong, and they
will be hard to debug for the *users* of the libraries that provide
this stuff. (One reason is that the easy generalization from 1-2
simple examples often fails for non-obvious reasons.)

Therefore I think the LINQ approach, which (IIUC) converts an
expression into a parse tree when certain syntax is encountered, and
calls a built-in method with that parse tree, would be a fresh breath
of air. No need deriding it just because Microsoft came up with it

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list