-1

I am trying to build a Strategy Pattern using S.Lott's response.
Problem is function returns None.
Am using Hickey's Simple vs Easy {what, how, who}-logic.
-[WHAT] I/O

class base_fnc(object):
    def fncExc(self,data1,data2):
        return

-[HOW] DATA <> queue[where,when] (direct injection)

class stump( base_fnc ):
    def fncExc(self, d1, aContext):
       return d1

class MAB(base_fnc ):
     def fncExc(self, d, aContext ):
        return d+10

-[WHO] API

class context( object ):
    def __init__(self, alt_how_class ):
        self.how = alt_how_class

    def exc(self, d ):
        return self.how.fncExc(d, self)

if __name__ == "__main__":
    c1 = context(MAB())
    ss=c1.exc(10) 
    print ss

ss prints None

Community
  • 1
  • 1
syntax
  • 585
  • 1
  • 6
  • 17

1 Answers1

2

You're not returning in exc. You need to do return self.how.fncExc(d, self).

BrenBarn
  • 242,874
  • 37
  • 412
  • 384