Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 30 Online
OpenStudy (anonymous):

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?

OpenStudy (rsmith6559):

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?

OpenStudy (anonymous):

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.

OpenStudy (rsmith6559):

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.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
YoungBlood: STOP THE YELLOW NAME TAG SLANDER!
4 hours ago 11 Replies 2 Medals
Bubblezz: Art for @euphoriiic
7 hours ago 23 Replies 3 Medals
ilovemybf: i need more drawing ideas
8 hours ago 15 Replies 1 Medal
toga: what is a Mayuri
11 hours ago 3 Replies 1 Medal
Midnight97: Here is a beat I made let me know what y'all think
12 hours ago 24 Replies 2 Medals
toga: who thinks that there should be more titles
13 hours ago 5 Replies 0 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!