Odd handling of type.__init__ bases
Arnaud Delobelle
arnodel at googlemail.com
Thu Feb 28 18:38:28 EST 2008
On Feb 28, 10:50 pm, qu... at sparq.org wrote:
> I encountered an oddity in attempting to use a metaclass to perform mix-in
> inheritance for classes. I've attached a small demonstration file. Have I
> misunderstood the bases argument for type.__init__ or should this be submitted
> as a bug?
After a quick look at your example:
* you are mixing classic classes (abase) and new-style classes (A and
B), which often creates problems.
* type.__init__ does not set the base classes, type.__new__ does
this. What you want to achieve could be done with:
class meta3(type):
def __new__(cls, name, bases, dict):
bases += (abase,)
return type.__new__(cls, name, bases, dict)
HTH
--
Arnaud
More information about the Python-list
mailing list