Resisting the temptation to say “avoid this situation first,” one (not necessarily elegant) solution might be to wrap the methods explicitly:
class A: pass class B( A ): def foo( self ): print( 'B.foo') def bar( self ): print( 'B.bar') class C( A ): def foo( self ): print( 'C.foo') def bar( self ): print( 'C.bar') class D( B, C ): def foo( self ): return B.foo( self ) def bar( self ): return C.bar( self )
Alternatively, you can make the method definitions explicit without wrapping:
class D( B, C ): foo = B.foo bar = C.bar
source share