Expert Python Programming(Third Edition)
上QQ阅读APP看书,第一时间看更新

Super pitfalls

Now, back to the super() call. If you deal with multiple inheritance hierarchy, it can become problematic. This is mainly due to the initialization of classes. In Python, the initialization methods (that is, the __init__() methods) of base classes are not implicitly called in ancestor classes if ancestor classes override __init__(). In such cases, you need to call superclass methods explicitly, and this can sometimes lead to initialization problems.

In this section, we will discuss a few examples of such problematic situations.