Is it possible to inheret a metaclass.
Peter Otten
__peter__ at web.de
Thu Apr 9 12:37:48 EDT 2020
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'>
More information about the Python-list
mailing list