[Tutor] error message with multiple inheritance
Kent Johnson
kent37 at tds.net
Wed Jun 11 12:47:44 CEST 2008
On Wed, Jun 11, 2008 at 2:25 AM, simone <simozack at yahoo.it> wrote:
> Christopher Spears ha scritto:
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> TypeError: Error when calling the metaclass bases
>> Cannot create a consistent method resolution
>> order (MRO) for bases B, A
>>
>> What does this error message mean? The example worked in the book. I
>> checked in the docs and could not find anything.
>
> http://www.python.org/download/releases/2.3/mro/
In layman's terms:
For class C, the method resolution order is C, B, A, object. Note that
B is before A. For class D, A would come before B because of the order
of declaration of base classes. This conflict causes the TypeError.
One way to fix it is to define D as
class D(B, A):
pass
Kent
More information about the Tutor
mailing list