Re: Distinction between “class” and “type”

Michael Selik michael.selik at gmail.com
Fri May 13 14:28:38 EDT 2016


On Fri, May 13, 2016 at 1:10 AM Ben Finney <ben+python at benfinney.id.au>
wrote:

> Howdy all,
>
> Ever since Python's much-celebrated Grand Unification of classes and
> types, I have used those terms interchangeably: every class is a type,
> and every type is a class.
>
> That may be an unwise conflation. With the recent rise of optional type
> annotation in Python 3, more people are speaking about the important
> distinction between a class and a type.
>

The concept of a type existed before the concept of object-oriented
programming. A type is more of a mathematical concept. Do some reading on
"type theory" if you'd like to know more. A type system ideally allows
logical deductions about the validity of your expressions/statements. Stuff
a static analyzer is good at.

With the advent of object-orientation and the concept of inheritance,
things have gotten a little confused. You could make a distinction between
"type inheritance" and "implementation/code inheritance" but many languages
do not. When you make a subclass in Python, it inherits both the type and
the code of the superclass. I suppose you could say the composition vs
inheritance argument stems from some people advocating code inheritance
without type inheritance.



More information about the Python-list mailing list