Clarence wrote: > I'm having problems creating classes because of "can't create a > consistent mro" problems. > > I noticed, in a test program, that if the base class list that I > pass to type.__new__ is sorted (using default keys, so presumably > sorting by the id's of the class objects), that the problem goes away. > > Now in this test, the id's (memory addresses) of the class objects > are presumably in the same order as the chronological order that > the classes were created in (since the program is simple and doesn't > delete any objects or make any temporaries). This may sound weird, > but I don't actually care what order the base classes appear in as > long as they're all there. > > This makes me wonder, since I can't say I understand the theory > (I read the paper referenced in typeobject.c source, my brain > didn't _quite_ melt) > behind mro creation, if it is the case that there cannot be a > consistency problem if each class in the base list was created > after all classes that precede it in the base list. > > Can any genius weigh in on this question? > Without wishing to lay claim to genius, I'd suggest that you don;'t write programs relying on multiple inheritance until you have a thorough understanding of its principles.
The inability of the interpreter to create a consistent mro has nothing to do with the order in which the base classes were created or where they appear in memory. It's probably because you have introduced a circularity: you are trying to define something based on A, which is based on B, which is based on A or something similar. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list