invoking a method from two superclasses
pavlovevidence at gmail.com
Tue Jun 30 21:23:11 EDT 2009
On Jun 30, 5:34 pm, Mitchell L Model <MLMLi... at 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):
> 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 C(A, B):
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
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.
More information about the Python-list