[Python-Dev] __contains__ hook

Greg Ward gward@cnri.reston.va.us
Wed, 2 Feb 2000 11:44:48 -0500


On 02 February 2000, Guido van Rossum said:
> I like the idea of overloading 'in' (and 'not in') with __contains__.
> There are several issues with this patch though (apart from the fact
> that he left out the disclaimer from
> http://www.python.org/1.5/bugrelease.html :-).

I agree at a language level; the current way to "overload" 'in' is...
ummm... weird.  It seems like there's a a simple and natural "magic
method" corresponding to almost every operator, so any operators that
*don't* get that treatment are second-class citizens.

As for the implementation of __contains__, I'm just not familiar enough
with Python internals to comment.  I'll let the rest of you argue over
that.

        Greg