Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Created August 17, 2020 18:27
Show Gist options
  • Save Sean-Bradley/e5b023e1fe1cfa33df7a9f9b63afc51e to your computer and use it in GitHub Desktop.
Save Sean-Bradley/e5b023e1fe1cfa33df7a9f9b63afc51e to your computer and use it in GitHub Desktop.
from abc import ABCMeta, abstractmethod
import datetime
class IComponent(metaclass=ABCMeta):
@staticmethod
@abstractmethod
def method(self):
"""A method to implement"""
class Component(IComponent):
def method(self):
print("The method has been called")
class ProxyComponent(IComponent):
def __init__(self):
self.component = Component()
def method(self):
f = open("log.txt", "a")
f.write("%s : method was proxied\n" % (datetime.datetime.now()))
self.component.method()
COMPONENT1 = Component()
COMPONENT1.method()
COMPONENT2 = ProxyComponent()
COMPONENT2.method()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment