• Is it possible to inheret a metaclass.

    From Antoon Pardon@1:261/38 to All on Thu Apr 9 18:11:22 2020
    From: Antoon Pardon <antoon.pardon@rece.vub.ac.be>

    I am experimenting with subclasses that all need the same metaclass as the base
    class. Is there a way to make the metaclass be inherited, so that you don't have to repeat the "metaclass = MetaClass" with every subclass.

    --
    Antoon Pardon.

    --- BBBS/Li6 v4.10 Toy-4
    * Origin: Prism bbs (1:261/38)
  • From Peter Otten@1:261/38 to All on Thu Apr 9 18:37:48 2020
    From: Peter Otten <__peter__@web.de>

    Antoon Pardon wrote:

    I am experimenting with subclasses that all need the same metaclass as the base class. Is there a way to make the metaclass be inherited, so that you don't have to repeat the "metaclass = MetaClass" with every subclass.

    ?

    This is not only possible, this is the default:

    class Pardon(type): pass
    ...
    class A(metaclass=Pardon): pass
    ...
    class B(A): pass
    ...
    type(B)
    <class '__main__.Pardon'>

    --- BBBS/Li6 v4.10 Toy-4
    * Origin: Prism bbs (1:261/38)