Difference between type and class

Nikolaus Rath Nikolaus at rath.org
Thu Jul 31 10:46:28 EDT 2008


Maric Michaud <maric at aristote.info> writes:
>> > Can someone explain to me the difference between a type and a class?
>>
>> If your confusion is of a more general nature I suggest reading the
>> introduction of `Design Patterns' (ISBN-10: 0201633612), under
>> `Specifying Object Interfaces'.
>>
>> In short: A type denotes a certain interface, i.e. a set of signatures,
>> whereas a class tells us how an object is implemented (like a
>> blueprint). A class can have many types if it implements all their
>> interfaces, and different classes can have the same type if they share a
>> common interface. The following example should clarify matters:
>>
>
> Of course, this is what a type means in certain literature about OO
> (java-ish), but this absolutely not what type means in Python. Types
> are a family of object with a certain status, and they're type is
> "type", conventionnaly named a metatype in standard OO.
[...]

Hmm. Now you have said a lot about Python objects and their type, but
you still haven't said what a type actually is (in Python) and in what
way it is different from a class. Or did I miss something?


Best,

   -Nikolaus

-- 
 »It is not worth an intelligent man's time to be in the majority.
  By definition, there are already enough people to do that.«
                                                         -J.H. Hardy

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C



More information about the Python-list mailing list