Hi,

I've been staring at this problem, in various forms, all day.  Am I missing 
something obvious, or is there some strange hardwiring of isinstance?  This is 
with Python 3.2.

        class A(metaclass=ABCMeta):
            @classmethod
            def __instancecheck__(cls, instance): return False
        # no override
        assert isinstance(A(), A)
        assert A.__class__.__instancecheck__(A, A())
        
        class B(type):
            def foo(self): return 42
        class C(metaclass=B):
            @classmethod
            def foo(cls): return 7
        # override
        assert C().__class__.foo() == 7

It seems to me that the above two cases are inconsistent.  ABCMeta declares 
__instancecheck__ just like B declares foo.  Yet C can override foo, but A is 
unable to override the instance check.

Please help!

Thanks,
Andrew
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to