Path: csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!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; 'modified': 0.05; 'exception.': 0.07; 'exist,': 0.07; 'cc:addr:python-list': 0.09; 'exist.': 0.09; 'keyed': 0.09; 'subject:ctypes': 0.09; 'thu,': 0.15; '10:59': 0.16; 'argh,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'missing?': 0.16; 'normal,': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; "shouldn't": 0.18; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'meant': 0.22; 'are.': 0.22; 'trying': 0.22; 'am,': 0.23; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'figure': 0.27; 'define': 0.27; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'exists,': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'certain': 0.31; 'post': 0.31; 'skip:_ 10': 0.32; 'getting': 0.33; "d'aprano": 0.33; 'is?': 0.33; 'raising': 0.33; 'steven': 0.33; 'received:google.com': 0.35; 'instance': 0.35; 'asking': 0.35; 'but': 0.36; 'list,': 0.36; 'there': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'method': 0.37; 'wrong': 0.38; 'hi,': 0.38; 'end': 0.39; 'why': 0.39; 'does': 0.39; 'still': 0.40; 'default': 0.61; 'yes': 0.62; 'course': 0.62; 'you.': 0.64; '>>>>>': 0.66; 'chrisa': 0.84; 'of?': 0.84 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:to :cc:content-type; bh=Y9jat9Z3xljjvTqf37I6tqxe9R/6g7Wj3dR+epF5bJk=; b=mcT6glsvDd/rdWxPbK0nMduxTQZ1uN6VOL3UzRIyHEnssHSu3BCCz5hC3PBeBHssii 9nHOM2HUVPUTAHoEDzBoQRLO1b1syHxX1G7lsuI7ySS4o/SrtcwLqRn//3wQrR2YYycB 5mPT2WYZVUtEzRsj4mVpV5OWQf6jvh2lebyJjbNMbo9JF5Hkm4pjrVrS6hNYSK1k7F6H fKHWT/luwDzFlBotoWtlPEuHgj5G6oz867adM6iR7BtRu5pSy7X2puuDJxJdAETrh/9F 1luy3e5uRFI/NlXpHa64+NK6zevUfRJZeRkniaMOhPB4p6dnyyTHlQB742N/ZJ2XfPtc ssHQ== MIME-Version: 1.0 X-Received: by 10.50.21.10 with SMTP id r10mr1710621ige.94.1440732348661; Thu, 27 Aug 2015 20:25:48 -0700 (PDT) In-Reply-To: <55dfcf4e$0$1663$c3e8da3$5496439d@news.astraweb.com> References: <55df099e$0$1638$c3e8da3$5496439d@news.astraweb.com> <55dfcf4e$0$1663$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 28 Aug 2015 13:25:48 +1000 Subject: Re: isinstance() and multiple inheritance/ctypes From: Chris Angelico To: "Steven D'Aprano" Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440732351 news.xs4all.nl 23743 [2001:888:2000:d::a6]:54950 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95716 On Fri, Aug 28, 2015 at 1:02 PM, Steven D'Aprano wrote: > On Fri, 28 Aug 2015 12:33 am, Chris Angelico wrote: > >> On Thu, Aug 27, 2015 at 10:59 PM, Steven D'Aprano >> wrote: >>> On Thu, 27 Aug 2015 09:14 am, Chris Angelico wrote: >>> >>>> On Thu, Aug 27, 2015 at 9:12 AM, Chris Angelico >>>> wrote: >>>>> Or is there a magic __isinstance__ >>>> >>>> Argh, keyed the wrong thing and sent the post prematurely. Meant to say: >>>> >>>> Or is there a magic __instancecheck__ method somewhere that I'm not >>>> aware of? >>> >>> Yes -- see Terry Reedy's post. >>> >>> isinstance(inst, klass) ends up calling >>> >>> type(klass).__instancecheck__(klass, inst) >> >> I'm aware that it _can_ exist, but I was asking if one _did_ exist. > > > Er, I'm still not getting you. Of course one exists, otherwise isinstance > would end up raising an exception. > > py> type.__instancecheck__ > > > What am I missing? Hi, I'm trying to figure out why my object is coming out as an instance of list, when it shouldn't be. 1) Is it really the object you think it is? 2) Does that type of object define __instancecheck__? There are certain normal, default expectations. We all know what those are. I was asking if these expectations had been modified in any way. ChrisA