Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108578

Distinction between “class” and “type”

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Distinction between “class” and “type”
Date Fri, 13 May 2016 15:07:04 +1000
Lines 35
Message-ID <mailman.623.1463116040.32212.python-list@python.org> (permalink)
References <85eg96eebr.fsf@benfinney.id.au>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de W73NC+xVwsTv90RLaGKdwgXwENGewKCsl/12rwzHUldg==
Cancel-Lock sha1:QCZ0+bQTxKYcqvW+8MWNdsd1zPI=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'guido': 0.05; 'tries': 0.05; 'url:pipermail': 0.05; 'important,': 0.07; 'type,': 0.07; 'optional': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'around!': 0.16; 'distinction': 0.16; 'instantiate': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:between': 0.16; 'unions': 0.16; 'unwise': 0.16; 'all,': 0.20; '(the': 0.22; 'variables.': 0.22; '(you': 0.23; "python's": 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'moved': 0.27; 'expose': 0.29; 'pep': 0.29; 'classes': 0.30; 'class.': 0.30; 'e.g.': 0.30; 'class': 0.33; 'url:python': 0.33; 'clear': 0.35; 'but': 0.36; 'url:org': 0.36; 'to:addr:python- list': 0.36; 'received:org': 0.37; 'things': 0.38; 'why': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'ever': 0.60; 'care': 0.60; 'more': 0.63; 'to,': 0.63; 'between': 0.65; 'inherit': 0.66; 'subjectcharset:utf-8': 0.71; 'truth': 0.79; '_o__)': 0.84; 'brain,': 0.84; 'received:125': 0.84
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <85eg96eebr.fsf@benfinney.id.au>
Xref csiph.com comp.lang.python:108578

Show key headers only | View raw


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?

And why is this distinction important, and who moved my cheesecake?

-- 
 \        “It is the responsibility of intellectuals to tell the truth |
  `\                    and to expose lies.” —Noam Chomsky, 1967-02-23 |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Distinction between “class” and “type” Ben Finney <ben+python@benfinney.id.au> - 2016-05-13 15:07 +1000
  Re: Distinction between “class” and “type” Rustom Mody <rustompmody@gmail.com> - 2016-05-12 22:21 -0700
  Re: Distinction between “class” and “type” Paul Rubin <no.email@nospam.invalid> - 2016-05-12 23:42 -0700
    Re: Distinction between “class” and   “type” Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-13 20:24 +1200
  Re: Distinction between “class” and “type” Steven D'Aprano <steve@pearwood.info> - 2016-05-14 15:05 +1000

csiph-web