Re: Is it possible to inheret a metaclass.

2020-04-11 Thread Peter Otten
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 =

Re: Is it possible to inheret a metaclass.

2020-04-11 Thread Pieter van Oostrum
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

Re: Is it possible to inheret a metaclass.

2020-04-10 Thread Greg Ewing via Python-list
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.

Re: Is it possible to inheret a metaclass.

2020-04-10 Thread Pieter van Oostrum
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

Re: Is it possible to inheret a metaclass.

2020-04-10 Thread Antoon Pardon
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

Re: Is it possible to inheret a metaclass.

2020-04-09 Thread 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 is not only possible, this is the default:

Is it possible to inheret a metaclass.

2020-04-09 Thread Antoon Pardon
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