[Python-Dev] type vs. class terminology
ncoghlan at gmail.com
Mon Nov 26 07:54:20 CET 2012
On Mon, Nov 26, 2012 at 3:01 PM, Chris Jerdonek <chris.jerdonek at gmail.com>wrote:
> I would like to know when we should use "class" in the Python 3
> documentation, and when we should use "type." Are these terms
> synonymous in Python 3, and do we have a preference for which to use
> and when?
> I'm sure this has been discussed before. But if this terminology
> issue has already been resolved, the resolution doesn't seem to be
> reflected in the docs. For example, the glossary entries for type and
> class don't reference each other.
The historical distinction between "builtin types" and "user-defined
classes" predates new-style classes (which unified the type system) and
Python 3 (which eliminated the "instance" type that was provided to
preserve the legacy user-defined class semantics in Python 2). The glossary
unfortunately still reflects this distinction, which no longer exists in
A slightly more useful distinction would be if type was used consistently
to refer to type(x), while class was used to refer to x.__class__, since
they can and do differ in the case of proxy types (like weakref.proxy).
However, it's probably too late for that kind of fine distinction - in
reality, the two terms are now used pretty much interchangeably.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev