Re: Distinction between “class” and “type”
Terry Reedy
tjreedy at udel.edu
Fri May 13 18:28:05 EDT 2016
On 5/13/2016 1:07 AM, Ben Finney 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.
>
> This recent message from GvR, discussing a relevant PEP, advocates
> keeping them separate:
>
> PEP 484 […] tries to make a clear terminological between classes
> (the things you have at runtime) and types (the things that type
> checkers care about).
>
> There's a big overlap because most classes are also types -- but not
> the other way around! E.g. Any is a type but not a class (you can
> neither inherit from Any nor instantiate it), and the same is true
> for unions and type variables. […]
>
> <URL:https://mail.python.org/pipermail/python-ideas/2016-May/040237.html>
>
> As a Bear of Little Brain, this leaves me clueless. What is the
> distinction Guido alludes to, and how are Python classes not also types?
I suspect that one could produce a class that is not a type, in Guido's
meaning, with a metaclass that is not a subclass of the type class. I
don't otherwise know what Guido might have meant.
--
Terry Jan Reedy
More information about the Python-list
mailing list