Really stupid question regarding PEP 252 and type/class unification

Russell Turpin russell_turpin at
Fri Aug 31 00:57:43 CEST 2001

Guido van Rossum <guido at> wrote in message news:<cp3d6ap71x.fsf at>...
> Indeed, you can't subclass from multiple built-in types.  But 
> you can subclass from multiple user-defined classes that derive 
> from the same built-in type. ..
> The complete rule that explains what combinations are cool is 
> a bit complex, but a simplified version is easy enough to 
> remember: you can multiply inherit from user-defined new-style 
> classes as long as they all derive from the same built-in type, 
> or from object.

OK, I think I'm grokking it. In future Python, every derived
type will descend from some ur-type, either one of the 
built-in types such as "list" or "dictionary," or "object,"
which is the ur-type for classes. Multiple inheritance is
allowed only within the ur-type, i.e., when all base types
have the same ur-type.

Two things occur to me. (1) The language is awkward. I want
a word for the union of Python types and classes. Above, I
use "data type," but that brings the obvious ambiguity. The
unification PEP might be an opportune time for some 
rationalization of the language. (2) If I have grokked the
future data model correctly, it seems to me that "Object" 
should be made a built-in type that follows all the same
rules as the other built-in types, distinguished primarily
as being the default base type when no other is listed. In 
particular, I should be able to create instances without 
first sub-classing:

    spam = Object()       # Create new instance
    spam.eggs = "Yes"

That would be neat.

Still .. I'm puzzled as to how subtyping affects mutability
and identity. If I subtype int, is the result immutable? 
What does that mean if I can assign attribute values? I 
haven't thought about this much, so I apologize if my 
comments are headed in the wrong direction.


More information about the Python-list mailing list