Skip to content

Instantly share code, notes, and snippets.

@metametaclass
Last active June 15, 2021 10:23
Show Gist options
  • Save metametaclass/b7770986535a049c79d5ee2379d3d819 to your computer and use it in GitHub Desktop.
Save metametaclass/b7770986535a049c79d5ee2379d3d819 to your computer and use it in GitHub Desktop.
class DHCP:
def dhcp_test(self):
self.executor.exec_command("dhcp test")
class Client(DHCP):
def __init__(self, executor):
self.executor = executor
class Executor:
def exec_command(self, cmd):
print(cmd)
class Executor2:
def exec_command(self, cmd):
print("begin exec")
print(cmd)
print("end exec")
client = Client(Executor())
client.dhcp_test();
client2 = Client(Executor2())
client2.dhcp_test();
class DHCP:
def dhcp_test(self):
self.exec_command("dhcp test")
class Executor:
def exec_command(self, cmd):
print(cmd)
class Client(Executor, DHCP):
pass
class Executor2:
def exec_command(self, cmd):
print("begin exec")
print(cmd)
print("end exec")
class Client(Executor, DHCP):
pass
class Client2(Executor2, DHCP):
pass
client = Client()
client.dhcp_test();
client2 = Client2()
client2.dhcp_test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment