eryksun added the comment:

Since Python has multiple inheritance, it could be misconstrued as a 
conjunctive test. For example, if c is an instance of C, which subclasses both 
A and B, then someone might think isinstance(c, (A, B)) requires c to be an 
instance of both A and B. The description could clarify that it's a disjunctive 
test with short circuiting.

    class MetaA(type):
        def __instancecheck__(self, other):
            print('MetaA.__instancecheck__')
            return False

    class A(metaclass=MetaA): pass

    >>> isinstance(1, (A, int))
    MetaA.__instancecheck__
    True
    >>> isinstance(1, (int, A))
    True

----------
keywords: +easy
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25432>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to