Tried that. Got: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
You should probably try the example you're trying to post before posting it. > On 31 Dec 2019, at 19:19, Soni L. <fakedme...@gmail.com> wrote: > > Okay. How about this then: > > class MM(type): > def __subclasscheck__(self, subclass): > return issubclass(subclass, type) > > > class M(type, metaclass=MM): > pass > > > class N(type): > pass > > > class C(metaclass=M): > pass > > > class D(metaclass=N): > pass > > > class E(C, D, metaclass=N): > pass > > > def main(): > assert type(E) is N and issubclass(E, C) > > > main() > >> On 2019-12-31 3:16 p.m., Anders Hovmöller wrote: >> You forgot something in that example I think because it doesn't actually do >> anything that can "not work". >> >> > On 31 Dec 2019, at 18:41, Soni L. <fakedme...@gmail.com> wrote: >> > > I would like this code to work, but currently python ignores >> > > __subclasscheck__ in many places where it checks for subclasses: >> > > class MM(type): >> > def __subclasscheck__(self, subclass): >> > return issubclass(subclass, type) >> > > > class M(type, metaclass=MM): >> > pass >> > > > class N(type): >> > pass >> > > > class C(metaclass=M): >> > pass >> > > > class D(metaclass=N): >> > pass >> > > > class E(C, D, metaclass=N): >> > pass >> > > > def main(): >> > e = E() >> > > > main() >> > _______________________________________________ >> > Python-ideas mailing list -- python-ideas@python.org >> > To unsubscribe send an email to python-ideas-le...@python.org >> > https://mail.python.org/mailman3/lists/python-ideas.python.org/ >> > Message archived at >> > https://mail.python.org/archives/list/python-ideas@python.org/message/4F6IQD5QIMDZ6BNVB7EZQ2HYKQ3KLZB3/ >> > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7RK36QIPNUD3F46MECDXNGVIGPS37TQY/ Code of Conduct: http://python.org/psf/codeofconduct/