Problem set 5 no. 6 The solution for the not trigger is class NotTrigger(Trigger): def __init__(self, trigger) self.t = trigger def evaluate(self, story): return not self.t.evaluate(story) I'm unclear as to how the evaluate method works here, is it calling itself? How exactly does self.t.evaluate(story) work behind the scene to produce the desired trigger?
I suspect that there are two evaluate methods in this program. The first is self.elvaluate, and the other is t.evaluate. self.t names a variable, self.t.evaluate() calls the evaluate method OF the self.t datatype. t.evaluate is recursive, self.evaluate is wrapping t.evaluate (getting it started). The key to this would be: what type of data/object is t?
Hi, Thanks for your response. There are several evaluate methods but those evaluate methods are defined in other classes, for other trigger. In this part there is only one evaluate method. The problem set itself has more context that makes it clearer I guess.
There is only one evaluate method defined in your code, there's two evaluate methods that will run ( NotTrigger.evaluate calls NotTrigger.t.evaluate, which is recursive ) if NotTrigger.evaluate is called.
Join our real-time social learning platform and learn together with your friends!