[Python-Dev] [1.6]: UserList, Dict: Do we need a UserString class?

Guido van Rossum guido@python.org
Wed, 29 Mar 2000 07:35:33 -0500


> > What's wrong with my implementation of __hash__ raising a TypeError with
> > the attribution 'unhashable object'. 
> 
> A subtype shouldn't change contracts of its supertypes. hash() was
> implicitly contracted as "raising no exceptions".

Let's not confuse subtypes and subclasses.  One of the things implicit
in the discussion on types-sig is that not every subclass is a
subtype!  Yes, this violates something we all learned from C++ -- but
it's a great insight.  No time to explain it more, but for me, Peter's
subclassing UserString for MutableString to borrow implementation is
fine.

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