Why Isn't Multiple Inheritance Automatic in Python?

Terry Reedy tjreedy at udel.edu
Mon Dec 17 23:36:13 CET 2012

On 12/17/2012 4:14 AM, Ian Kelly wrote:
> On Sun, Dec 16, 2012 at 9:30 PM, Nick M. Daly <nick.m.daly at gmail.com> wrote:
>> It's very unlikely that multiple inheritance would go horribly wrong, as
>> long as classes adopt class-specific argument naming conventions.
>> However, ever since bug 1683368 [0] was fixed, it's now impossible to
>> cleanly create arbitrary inheritance trees.
> No, it isn't.  You just code each class to strip out the particular
> arguments that it uses, and by the time you get up to object, either
> you've removed all the arguments, or your inheritance tree is buggy.
> The fix for bug 1683368 means that this latter case is detected and
> raised as an error.

In other words, one could say that the fix forces a clean inheritance tree.

> There was a thread not too long ago about the fact that this fix was
> recently extended to the __init__ methods of immutable classes,

Since 3.3.0?
 >>> object.__init__(object(), 1)
Traceback (most recent call last):
   File "<pyshell#4>", line 1, in <module>
     object.__init__(object(), 1)
TypeError: object.__init__() takes no parameters
 >>> tuple.__init__(tuple(), 1)

Or were you referring to something else? Or done since?

> while I'm not convinced that this was the correct thing to do, Terry
> Reedy pointed out in the issue comments back in 2010 that the proper
> way to initialize immutable instances is by overriding __new__ rather
> than __init__, the former of which is still perfectly clean to
> inherit.

It seems to me that tuple, etc., should just inherit __init__ from object.

Terry Jan Reedy

More information about the Python-list mailing list