ian.g.kelly at gmail
Jun 5, 2012, 3:39 AM
Post #3 of 4
On Tue, Jun 5, 2012 at 2:48 AM, Steven D'Aprano
<steve+comp.lang.python [at] pearwood> wrote:
> I was playing around with metaclasses and I wondered what would happen if
> the metaclass itself had a metaclass. Sort of a metametaclass.
> Apparently it gives an error. Can anyone explain why this does not work?
In your example, Meta is not actually a metaclass, as it inherits from
object, not type. Here's an example that works:
>>> class MetaMeta(type): pass
>>> class Meta(type, metaclass=MetaMeta): pass
>>> class MyClass(metaclass=Meta): pass
Anyway, metaclasses of metaclasses is not that unusual, as type is
already its own metaclass.