Re: Metaclass of a metaclass
- From: "bruno.desthuilliers@xxxxxxxxx" <bruno.desthuilliers@xxxxxxxxx>
- Date: Tue, 5 Jun 2012 08:30:57 -0700 (PDT)
On Jun 5, 10:48 am, Steven D'Aprano <steve
+comp.lang.pyt...@xxxxxxxxxxxxx> wrote:
Apparently it gives an error. Can anyone explain why this does not work?
# Python 3.2
class MyType(type): # A metaclass...
... def __repr__(self):
... s = super().__repr__()
... return s.replace('class', 'metaclass')
class Meta(metaclass=MyType): # ... of a metaclass.
... pass
(...)
class MyClass(metaclass=Meta): # And now try to use it.
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters
What am I doing wrong?
Meta inherit from object, but being used as a metaclass, Meta.__new__
is called with name, bases, dict etc as arguments.
.
- References:
- Metaclass of a metaclass
- From: Steven D'Aprano
- Metaclass of a metaclass
- Prev by Date: Re: what gui designer is everyone using
- Next by Date: Re: fputs
- Previous by thread: Metaclass of a metaclass
- Next by thread: fputs
- Index(es):
Relevant Pages
|