How do I call a method on a specific base class in Python?
inheritance, python
Solution
Just name the "base class".
If you wanted to call say `B.test` from your `C` class:
class C(A,B):
def test(self):
B.test(self)
Example:
class A(object):
def test(self):
print 'A'
class B(object):
def test(self):
print 'B'
class C(A, B):
def test(self):
B.test(self)
c = C()
c.test()
Output:
$ python -i foo.py
B
>>>
See: Python Classes (Tutorial)
Problem
How do I call a method on a specific base class? I know that I can use `super(C, self)` in the below example to get automatic method resolution - but I want to be able to specify which base class's method I am calling? ``` class A(object): def test(self): print 'A' class B(object): def test(self): print 'B' class C(A,B): def test(self): print 'C' ```