Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'subject:Python': 0.06; 'correct.': 0.07; 'agree,': 0.09; 'assuming': 0.09; 'attributes': 0.09; 'instance.': 0.09; 'method,': 0.09; 'method:': 0.09; 'methods,': 0.09; 'useless': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; '5:00': 0.16; 'attribute.': 0.16; 'belongs': 0.16; 'callable': 0.16; 'defined,': 0.16; 'definition.': 0.16; 'iterable:': 0.16; 'new-style': 0.16; 'old- style': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'things.': 0.19; 'feb': 0.22; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'saying': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'class.': 0.26; 'define': 0.26; 'defined': 0.27; 'header:In-Reply- To:1': 0.27; 'on,': 0.29; 'am,': 0.29; 'properties': 0.29; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; "d'aprano": 0.31; 'ok.': 0.31; 'steven': 0.31; 'class': 0.32; 'probably': 0.32; 'url:python': 0.33; 'skip:_ 10': 0.34; 'subject: (': 0.35; 'agree': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'instances': 0.36; "didn't": 0.36; 'method': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'called': 0.40; 'even': 0.60; 'free': 0.61; 'making': 0.63; 'personal': 0.63; 'such': 0.63; 'different': 0.65; 'body.': 0.68; 'realized': 0.68; 'subject:! ': 0.74; '2015': 0.84; 'hand.': 0.84; 'subject:!)': 0.84; 'involved.': 0.91; 'thing,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=fK5qhf43546six3iwmwYZ3faTPY1CvfCaftaCkzdYvk=; b=tr5kTuHzzQFBW45H87VJlAFSA4LC38SVqTnrV7dmIs6TITeCxCNcNrg6EzObRx8bXU G3vMu5GbKpYiXBlan47BFJzXjzJBsjtjOcCJc9LIB6n6nr8ddEuf/6rZM4FNmSVwdkYp GRd6HMoewCo96eNGdabr6rHLKIRBr9z8izWiM+t4FGcVGminRiprZzY97KFnG7j5gj4s +7JhmElDDsyKYX1zPoWhluWQMhB0dtg/EhEqRHHBN4Kpu8DsRoXZ/s+EB10/5NCPi0Cw 8ujNVCoSXjGhD2IGbqznroT5fguTByf/2H9ET6i9AhGVhuk9sPtgCwuwsCbkRQ05Wj+R hQYg== X-Received: by 10.224.129.134 with SMTP id o6mr41547561qas.51.1422882199809; Mon, 02 Feb 2015 05:03:19 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54c07d04$0$13012$c3e8da3$5496439d@news.astraweb.com> <54c6d7c2$0$12992$c3e8da3$5496439d@news.astraweb.com> <54c83ab4$0$12982$c3e8da3$5496439d@news.astraweb.com> <54ca583e$0$13005$c3e8da3$5496439d@news.astraweb.com> <54ccc2fc$0$13009$c3e8da3$5496439d@news.astraweb.com> <54cd9a7a$0$12984$c3e8da3$5496439d@news.astraweb.com> <54ce526a$0$13012$c3e8da3$5496439d@news.astraweb.com> <54cf242d$0$12991$c3e8da3$5496439d@news.astraweb.com> <54cf6836$0$12996$c3e8da3$5496439d@news.astraweb.com> From: Devin Jeanpierre Date: Mon, 2 Feb 2015 05:02:39 -0800 Subject: Re: dunder-docs (was Python is DOOMED! Again!) To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422882208 news.xs4all.nl 2948 [2001:888:2000:d::a6]:58294 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85077 On Mon, Feb 2, 2015 at 5:00 AM, Devin Jeanpierre wrote: > On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano > wrote: >>> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano >>> wrote: >> Both K.f and K.g are methods, even though only one meets the definition >> given in the glossary. The glossary is wrong. > > I agree, it oversimplified and has made a useless distinction here. Oops, I just realized why such a claim might be made: the documentation probably wants to be able to say that any method can use super(). So that's why it claims that it isn't a method unless it's defined inside a class body. -- Devin >>>> Even if it is so defined, the definition is wrong. You can define methods >>>> on an instance. I showed an example of an instance with its own personal >>>> __dir__ method, and showed that dir() ignores it if the instance belongs >>>> to a new-style class but uses it if it is an old-style class. >>> >>> You didn't define a method, you defined a callable attribute. >> >> That is wrong. I defined a method: >> >> py> from types import MethodType >> py> type(instance.f) is MethodType >> True >> >> >> instance.f is a method by the glossary definition. Its type is identical to >> types.MethodType, which is what I used to create a method by hand. > > You are assuming that they are both methods, just because they are > instances of a type called "MethodType". This is like assuming that a > Tree() object is made out of wood. > > The documentation is free to define things in terms other than types > and be correct. There are many properties of functions-on-classes that > callable instance attributes that are instances of MethodType do not > have, as we've already noticed. isinstance can say one thing, and the > documentation another, and both can be right, because they are saying > different things. > > > For an example we can all agree on, this is not an instance of > collections.Iterable, but the docs claim it is iterable: > https://docs.python.org/2/glossary.html#term-iterable > > class MyIterable(object): > def __getitem__(self, i): return i > > The docs are not "wrong", they are just making a distinction for > humans that is separate from the python types involved. This is OK. > > -- Devin