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


Groups > comp.lang.python > #95716

Re: isinstance() and multiple inheritance/ctypes

References (1 earlier) <CAPTjJmrrFT3aE3vF8nZiw0uxWGCw18YyEFXvOPCtdQDRxiOY7Q@mail.gmail.com> <mailman.68.1440630846.11709.python-list@python.org> <55df099e$0$1638$c3e8da3$5496439d@news.astraweb.com> <mailman.75.1440686010.11709.python-list@python.org> <55dfcf4e$0$1663$c3e8da3$5496439d@news.astraweb.com>
Date 2015-08-28 13:25 +1000
Subject Re: isinstance() and multiple inheritance/ctypes
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.95.1440732351.11709.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Aug 28, 2015 at 1:02 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> On Fri, 28 Aug 2015 12:33 am, Chris Angelico wrote:
>
>> On Thu, Aug 27, 2015 at 10:59 PM, Steven D'Aprano <steve@pearwood.info>
>> wrote:
>>> On Thu, 27 Aug 2015 09:14 am, Chris Angelico wrote:
>>>
>>>> On Thu, Aug 27, 2015 at 9:12 AM, Chris Angelico <rosuav@gmail.com>
>>>> 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__
> <method '__instancecheck__' of 'type' objects>
>
> 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

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


Thread

isinstance() and multiple inheritance/ctypes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-08-26 21:21 +0000
  Re: isinstance() and multiple inheritance/ctypes Terry Reedy <tjreedy@udel.edu> - 2015-08-26 17:46 -0400
  Re: isinstance() and multiple inheritance/ctypes Chris Angelico <rosuav@gmail.com> - 2015-08-27 09:12 +1000
    Re: isinstance() and multiple inheritance/ctypes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-08-26 23:42 +0000
  Re: isinstance() and multiple inheritance/ctypes Chris Angelico <rosuav@gmail.com> - 2015-08-27 09:14 +1000
    Re: isinstance() and multiple inheritance/ctypes Steven D'Aprano <steve@pearwood.info> - 2015-08-27 22:59 +1000
      Re: isinstance() and multiple inheritance/ctypes Chris Angelico <rosuav@gmail.com> - 2015-08-28 00:33 +1000
        Re: isinstance() and multiple inheritance/ctypes Steven D'Aprano <steve@pearwood.info> - 2015-08-28 13:02 +1000
          Re: isinstance() and multiple inheritance/ctypes Chris Angelico <rosuav@gmail.com> - 2015-08-28 13:25 +1000

csiph-web