On 04/11/2019 14:33, Veek M wrote:

Aha.  You're trying to fix up the metaclass after the fact, which is not
the right way to do it.  If you change the class definitions to:

__metaclass__ = whatever; # is python2.x syntax

But not Python3: see PEP 3115

then you get the prints from MyMeta.__instancecheck__().  The
isinstance() still returns True, though, and I don't know why.  Then
again, your definition of MyMeta is really weird.

weird how..?
(I'm just trying to figure out what's going on with __instancecheck__ -
no further higher purpose :p)

example, when we do: isinstance(x, (A, B, C))
you expect from the docs that
A.__instancecheck__(cls, x) is passed but x = []
also, B and C.__instancecheck__ is not called when I return False

Also if I interchange (Bar, Foo), expecting that Foo.__instancecheck__
will be called, it's completely bypassed

That must be what's responsible for the True result. Logically the problem must be to do with your MyzMeta class then. I have no idea what.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to