[docs] [issue25432] isinstance documentation doesn't explain what happens when type is tuple

eryksun report at bugs.python.org
Sat Oct 17 13:25:21 EDT 2015

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):
            return False

    class A(metaclass=MetaA): pass

    >>> isinstance(1, (A, int))
    >>> isinstance(1, (int, A))

keywords: +easy
nosy: +eryksun

Python tracker <report at bugs.python.org>

More information about the docs mailing list