Ziga Seilnacht wrote: > - Since D does not have a __metaclass__ attribute, > its type is determined from its bases. > - Since A is the first base, its type (M_A) is called; > unfortunately this is not the way metaclasses are > supposed to work; the most derived metaclass should > be selected. > - M_A's __new__ method calls the __new__ method of the > next class in MRO; that is, super(M_1, meta).__new__ > is equal to type.__new__. > - In type.__new__, it is determined that M_A is not > the best type for D class; it should be actually M_B. > - Since type.__new__ was called with wrong metaclass > as the first argument, call the correct metaclass. > - This calls M_B.__new__, which again calls type.__new__, > but this time with M_B as the first argument, which > is correct.
This is a very good explanation and it should go somewhere in the standard docs. I remember I spent a significant amount of time and effort to reach the same conclusion a while ago, and now I have already started to forget eveything a again :-( Anyway, I will bookmark this post for future reference ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list