Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Last active July 16, 2020 02:51
Show Gist options
  • Save thanakijwanavit/d6bf5d5de9a52f3a1b287722c4f7f138 to your computer and use it in GitHub Desktop.
Save thanakijwanavit/d6bf5d5de9a52f3a1b287722c4f7f138 to your computer and use it in GitHub Desktop.
class B:
def random_func(self, i, j, test=None):
print(2)
class A:
def random_func(self, i, j, test=None):
print(1)
class ModA(A):
def random_funcA(self, i, j, test=None):
super().random_func(i, j, test=test)
class ModB(B):
def random_funcB(self, i, j, test=None):
super().random_func(i, j, test=test)
class MiddleClass(ModA,ModB):
pass
m = MiddleClass()
m.random_funcA(1, 3, test="hello")
m.random_funcB(1, 3, test= 'hello')
@thanakijwanavit
Copy link
Author

# option 2

class B:
    def random_func(self, i, j, test=None):
        print(2)
class A:
    def random_func(self, i, j, test=None):
        print(1)
        
class MiddleClass(A,B):
    def random_funcA(self, i, j, test=None):
        A.random_func(self,i,j,test=test)
    def random_funcB(self, i, j, test=None):
        B.random_func(self,i,j,test=test)

m = MiddleClass()
m.random_funcA(1, 3, test="hello")
m.random_funcB(1, 3, test= 'hello')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment