Simple metaclass code failing
LittleGrasshopper
seattlehanks at yahoo.com
Sun May 31 18:53:32 EDT 2009
On May 31, 3:52 pm, LittleGrasshopper <seattleha... at yahoo.com> wrote:
> This is some simple code which I got from Guido's paper on the
> unification of classes and types, which Arnaud suggested to improve my
> knowledge of metaclasses:
>
> class M1(type):
> pass
> class M2(M1):
> pass
> class M3(M2):
> pass
> class C1:
> __metaclass__ = M1
> class C2(C1):
> __metaclass__ = M2
> class C3(C1, C2):
> __metaclass__ = M3
>
> It is failing when processing C3:
> Traceback (most recent call last):
> File "metaerror.py", line 18, in <module>
> class C3(C1, C2):
> TypeError: Error when calling the metaclass bases
> Cannot create a consistent method resolution
> order (MRO) for bases C2, C1
>
> Since M3 is a subclass of M1 and M2 (which are the metaclasses for the
> bases of C3, I don't understand the error. Then again, the error seems
> to reference the MRO.
>
> I hope this is one of those posts that I can look back in a few months
> from now and think "Man, was that a dumb thing to ask!" Until then, I
> would appreciate your help in trying to figure out what's going on.
>
> Lukas
I forgot to say, this is Python 2.5.2 (in case that makes any
difference.)
More information about the Python-list
mailing list