Should one always add super().__init__() to the __init__?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Sep 30 00:40:22 EDT 2012


On Sat, 29 Sep 2012 17:51:29 -0400, Piet van Oostrum wrote:

> It is not necesarily calling the parent class. It calls the initializer
> of the next class in the MRO order and what class that is depends on the
> actual multiple inheritance structure it is used in, which can depend on
> subclasses that you don't know yet. This makes it even worse.

I don't quite follow you here. It sounds like you are saying that if you 
have these classes:

# pre-existing classes
class A(object): pass
class B(object): pass

# your class
class C(A, B): pass

and somebody subclasses A or B, the MRO of C will change. That is not 
actually the case as far as I can see.



-- 
Steven



More information about the Python-list mailing list