July 12th, 2005, 10:59 PM
Method Resolution Order (MRO) - Juicy!
I have been playing around with classes and the Singleton instance.
I noticed that if I do a multiple inheritance with the Singleton class and some other class with the Singleton class listed first in the inheritance order as "class a(Singleton, MainClass)" , I will get an error: "TypeError: Cannot create a consistent method resolution order (MRO) for class Singleton, MainClass".
Fortunately, reversing the order: class a(MainClass, Singleton) gets rid of the error.
I used the Singleton class as in the example I found - it inherits from nothing while MainClass inherits from a couple of other classes.
All of the classes are in separate modules and import statements are used. Class "MainClass" is the top class of the application.
I'm wondering though what is actually going on here.
Anyone have any thoughts or experience with this?
Maybe the fact that Singleton inherits from nothing?