From 4df2bd87a484402bb7a900eab9233792c9e5d312 Mon Sep 17 00:00:00 2001 From: Amin Memariani Date: Sat, 26 May 2018 06:16:09 +0430 Subject: [PATCH 1/2] Create strategy.py --- strategy.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 strategy.py diff --git a/strategy.py b/strategy.py new file mode 100644 index 0000000..1551f67 --- /dev/null +++ b/strategy.py @@ -0,0 +1,33 @@ +import types + + +class StrategyExample: + def __init__(self, func=None): + self.name = 'Strategy Example 0' + if func is not None: + self.execute = types.MethodType(func, self) + + def execute(self): + print(self.name) + + +def execute_replacement1(self): + print(self.name + ' from execute 1') + + +def execute_replacement2(self): + print(self.name + ' from execute 2') + + +if __name__ == '__main__': + strat0 = StrategyExample() + + strat1 = StrategyExample(execute_replacement1) + strat1.name = 'Strategy Example 1' + + strat2 = StrategyExample(execute_replacement2) + strat2.name = 'Strategy Example 2' + + strat0.execute() + strat1.execute() + strat2.execute() From 71efc68bd9cc8d87a94eec8237310701e9342c5a Mon Sep 17 00:00:00 2001 From: Amin Memariani Date: Wed, 30 May 2018 00:57:25 +0430 Subject: [PATCH 2/2] Rename strategy.py to 07_strategy/strategy.py --- strategy.py => 07_strategy/strategy.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename strategy.py => 07_strategy/strategy.py (100%) diff --git a/strategy.py b/07_strategy/strategy.py similarity index 100% rename from strategy.py rename to 07_strategy/strategy.py