Antoon Pardon wrote:
>
>
> Op 9/04/20 om 18:37 schreef Peter Otten:
>> 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 =
Pieter van Oostrum 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 __ini
On 11/04/20 12:19 am, Pieter van Oostrum wrote:
Your Pardon is not a class, it is a function.
To elaborate on that a bit, the way inheritance of metaclasses
works is that when you define a class, if you don't explicity
specify a metaclass, it uses the class of the base class as
the metaclass.
Antoon Pardon writes:
> Op 9/04/20 om 18:37 schreef Peter Otten:
>> 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 = Meta
Op 9/04/20 om 18:37 schreef Peter Otten:
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
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:
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.
--
https://mail.python.org/mailman/listinfo/python-list