On Jun 5, 10:48 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> 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. -- http://mail.python.org/mailman/listinfo/python-list