Created
August 17, 2020 18:27
-
-
Save Sean-Bradley/e5b023e1fe1cfa33df7a9f9b63afc51e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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