[Zope3-dev] Overloading 'is' (was: Nasty bugs)

Guido van Rossum guido@python.org
Wed, 20 Mar 2002 13:30:38 -0500


> A possible change to python where a class could define an __is__ slot 

Hm, I'm not sure I really like to allow overloading 'is'.  It sorta
against all expectations.  Ditto for type().

I would never have been able last night's problem if type() had
returned NoneType -- as it was, it showed that what I had in my hand
was a wrapper, and that was enough of a clue to unravel the mystery.

__class__ is different -- you're allowed to overload that, and in fact
I believe it's a bug that isinstance(x, C) doesn't believe x.__class__
(at least it doesn't when C is a new-style class or a built-in type).

--Guido van Rossum (home page: http://www.python.org/~guido/)