A class is a Python data structure that can be used as a template for instances of that class by calling it, e.g. foo = Foo()
.
A type is a class that can be used as a template for additional classes by way of inheritance, e.g. class Foo(Bar):
Since Python supports inheritance, all classes can be used as templates for additional classes, which means that all classes are in fact types.
This is especially true since the advent of "new-style classes," derived from object
, which unify the type hierarchy of user-defined classes with the built-in types. Classes were always types, but now they are the same kind of types as the built-in types.
Although Python classes are types, I still find the distinction a useful one, so the terms are not entirely synonyms in my mind.
Bonus definition: a metaclass is a class whose instances are classes. In Python, these must be derived from the type
class, just as new-style objects are derived from object.