Difference between type and class

Maric Michaud maric at aristote.info
Thu Jul 31 17:08:08 CEST 2008


Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit :
> 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?

This paragraph ?

"""
- types, or classes, are all instance of type 'type' (or a subclass of it), 
they can be instantiated and they produce objects (ordinary object in 
general) with theirslef as a type.
"""

Maybe it's still unclear that "types" and "classes" *are* synonyms in Python.

-- 
_____________

Maric Michaud



More information about the Python-list mailing list