Is it possible to inheret a metaclass.
Pieter van Oostrum
pieter-l at vanoostrum.org
Sat Apr 11 02:59:51 EDT 2020
Pieter van Oostrum <pieter-l at vanoostrum.org> writes:
> Your Pardon is not a class, it is a function. Class A is created by
> type(cls, *args), so 'type' is the metaclass of A, and therefore also of
> B.
> Creation of B does not call Pardon.
With a class it *does* work:
In [74]: class Pardon(type):
... def __init__(cls, *args):
... print("Calling Pardon with", cls)
In [75]: class A(metaclass=Pardon): pass
Calling Pardon with <class '__main__.A'>
In [76]: class B(A): pass
Calling Pardon with <class '__main__.B'>
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
More information about the Python-list
mailing list