On Jun 30, 5:34 pm, Mitchell L Model <mlmli...@comcast.net> wrote: > Allow me to add to my previous question that certainly the superclass > methods can be called explicitly without resorting to super(), e.g.: > > class C(A, B): > def __init__(self): > A.__init__(self) > B.__init__(self) > > My question is really whether there is any way of getting around the > explicit class names by using super()
Yes there is: just make sure that all subclasses also call super. class A: def __init__(self): super().__init__() print('A') class B: def __init__(self): super().__init__() print('B') class C(A, B): def __init__(self): super().__init__() print('C') Bam, that's it. What's happening is that A's super calls B. That is likely to seem wrong to someone who is very familiar with OOP, but it's how Python's MI works. Read this essay/rant that explains how super works and why the author thinks it's not useful. Then ignore the last part, because I and many others have found it very useful, desipte its drawbacks. http://fuhm.net/super-harmful/ Carl Banks -- http://mail.python.org/mailman/listinfo/python-list