Message253138
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 |
|
Date |
User |
Action |
Args |
2015-10-17 17:25:21 | eryksun | set | recipients:
+ eryksun, r.david.murray, docs@python, Michael Crouch |
2015-10-17 17:25:21 | eryksun | set | messageid: <1445102721.74.0.669873112683.issue25432@psf.upfronthosting.co.za> |
2015-10-17 17:25:21 | eryksun | link | issue25432 messages |
2015-10-17 17:25:21 | eryksun | create | |
|