Possible bug in "metaclass resolution order" ?

Michele Simionato michele.simionato at gmail.com
Sat Sep 17 11:51:50 EDT 2005


I think this is more of a documentation issue than of a bug.
It may seems strange at first, but __metaclass__ and __class__ may be
different.

For instance, if M is metaclass

>>> class C(object): pass

>>> C.__metaclass__ = M

you get a class with metaclass hook equal to M, but C.__class__ is
still 'type'.

In you example, setting the __metaclass__ to 'type' does not change the
metaclass of
the created class, which is inherited from the base class. I suggest
you to file a documentation
bug. Unfortunately the basic documentation about metaclasses is a bit
lacking and you have
to discover many things by trial and errors.

       Michele Simionato




More information about the Python-list mailing list