Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108581
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Distinction between “class” and “type” |
| Date | Fri, 13 May 2016 15:23:28 +1000 |
| Lines | 42 |
| Message-ID | <mailman.624.1463117015.32212.python-list@python.org> (permalink) |
| References | <85eg96eebr.fsf@benfinney.id.au> <CAPTjJmoGuAs8bFRFEW2Qyg9c9a5ntSFbew=_o24V9g8HUYBd1w@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de uWDXhOsw1PmD4xsouQjR1grI7mO8kkYtnlm2+36/9yRw== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'guido': 0.05; 'tries': 0.05; 'url:pipermail': 0.05; 'difference,': 0.07; 'important,': 0.07; 'cc:addr:python-list': 0.09; 'int.': 0.09; 'subclasses': 0.09; 'python': 0.10; '"things': 0.16; '2016': 0.16; 'around!': 0.16; 'distinction': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instantiate': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sequence,': 0.16; 'subject:between': 0.16; 'unions': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'variables.': 0.22; '(you': 0.23; 'examples': 0.24; 'header:In-Reply-To:1': 0.24; 'sense': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'moved': 0.27; 'sequence': 0.27; 'actual': 0.28; 'looks': 0.29; '13,': 0.29; 'pep': 0.29; 'str': 0.29; 'asked': 0.29; 'classes': 0.30; 'e.g.': 0.30; "can't": 0.32; 'maybe': 0.33; 'class': 0.33; 'problem': 0.33; 'url:python': 0.33; 'similar': 0.33; 'except': 0.34; 'received:google.com': 0.35; 'clear': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'expect': 0.37; 'things': 0.38; 'difference': 0.38; 'received:209': 0.38; 'why': 0.39; 'does': 0.39; 'url:mail': 0.40; 'care': 0.60; 'your': 0.60; 'to,': 0.63; 'between': 0.65; 'inherit': 0.66; "they're": 0.66; 'subjectcharset:utf-8': 0.71; 'brain,': 0.84; 'checker': 0.84; 'chrisa': 0.84; 'construct': 0.84; 'to:none': 0.91; 'thing,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-transfer-encoding; bh=rVxAU/Uj9lniSNhnDk/3pMWWVR+luqZ2CVCV40FFR+s=; b=JVBfgkrQQsA5KmfvXxQm++oz3/bEvHhrIMNxi6j8jwGOxn0JkFxUgyhIjas5haBojX sHcXeppPGVL9ZO58inA3JB8LKwwLigt67lz5LBclbftriV6KUvlz5M0jAWJJKGAsiEVe 0Sgai9hKTef/D9zrhpAuU13zWUzBP2lr7+roF5Lpj4WP32qSU0Qirt/GvzLSKWRmXqw4 gVkaLy2J3oXHK9oaHeyaF8+C4UCnFUZLwh9Z4/RzA0Dq7FLCAxypslyfhMvCuxzi8Q3I WHLAUKhIV0tAaGY3TAkZrJxQ+4YxTt0aZM+IEqPRHuDp6ryYoq5Cq1hHvevMMn6N38fS rdaQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-transfer-encoding; bh=rVxAU/Uj9lniSNhnDk/3pMWWVR+luqZ2CVCV40FFR+s=; b=c82HpF8A8dPnf1T/BhSPBjYihm8B/G3ygNMKDrs/fOsnY6R7dmAiSchRVWcBj0cwmw G8W7jM2BwP4MmcKrF9CRbjzB69p2c8vyy/9HA3vCUfHhnC7jbwTQlc0nLmWsBvDsIbFE y8mcU8jsQHGmMJF+LKlXGA572yv89F0QMtM4cxqzv8OFbzZAiL0MNMMgDIPoxlXunqYU GlKpBpj9ZcHdtZTudoM+WetdsZdVaZsmhpMal3SWoS+WY3CzGrBp40ti7mnzj1/xe+Xv WiiVKoYqVmv0qWkVRVlq4qoDTqUMskBEpdCjedi65UHrPAVzBOg/osxi/aqiEBCu46Dl 18Xw== |
| X-Gm-Message-State | AOPr4FXZHjz7jdEbm9f69r9/L8+DqMLjHmGdAMnQl7XhtE80+fzsVNLnvCH8w4EpOXsEkWaldRAywhDMJxZR9w== |
| X-Received | by 10.25.88.12 with SMTP id m12mr6037176lfb.42.1463117008598; Thu, 12 May 2016 22:23:28 -0700 (PDT) |
| In-Reply-To | <85eg96eebr.fsf@benfinney.id.au> |
| 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 | <CAPTjJmoGuAs8bFRFEW2Qyg9c9a5ntSFbew=_o24V9g8HUYBd1w@mail.gmail.com> |
| X-Mailman-Original-References | <85eg96eebr.fsf@benfinney.id.au> |
| Xref | csiph.com comp.lang.python:108581 |
Show key headers only | View raw
On Fri, May 13, 2016 at 3:07 PM, Ben Finney <ben+python@benfinney.id.au> wrote: > 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? The difference, as I understand it, is that types are abstract and classes are concrete. The problem is that 'type' is an actual concrete thing, so terminology is messy; but the examples are pretty clear - you can't instantiate Any the way you can instantiate str or int. There's a similar difference with ABCs like Sequence - you can't construct a Sequence, but you can document that you expect to be passed one. Maybe the solution is to have a new word for "things a type checker looks for"... except that that really does want to be, uhh, "types". Or maybe the solution is to have a new word for "things you can construct with the class keyword"... except that that that's "types" too, because they're all subclasses of 'type'. > And why is this distinction important, and who moved my cheesecake? Because it wouldn't make sense if you asked who moved your bacon. Mmm. Bacon. With cheesecake for afters. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Distinction between “class” and “type” Chris Angelico <rosuav@gmail.com> - 2016-05-13 15:23 +1000
csiph-web