I suspect that there may be an problem with the Prof class definition in the handout for lecture 16. The lecture function has three inputs (lecture(self,toWhom,something) and calls the say function. The say function, also defined in the class, has three inputs say(self,toWhom,something): If toWhom is a member of the Person class, sal calls self.lecture(something). self.lecture would require 2 arguments (other than self). Moreover, self.lecture would again call say. This is problematic. I suspect the last line in the definition should be changed from return self.lecture(something) to: r
does the handout version work? does your revised version work? use dpaste.com or ideone.com or codepad.com or pastebin.com or ....... to post your code pls.
class Prof(MITPerson): def __init__(self,familyName,firstName,rank): MITPerson.__init__(self,familyName,firstName) self.rank=rank self.teaching={} def addTeaching(self,term,subj): try: self.teaching[term].append(subj) except KeyError: self.teaching[term]=[subj] def getTeaching(self,term): try: return (self.teaching[term]) except KeyError: return (None) def lecture(self,toWhom,something): return (self.say(toWhom,something+ " as it is obvious")) def say(self,toWhom,something): if type(toWhom)==UG: return (MITPerson.say(self,toWhom,'I do not understand why you say ' + something)) elif type(toWhom)==Prof: return (MITPerson.say(self,toWhom,'I really liked your paper on ' +something)) else: return (Person.say(self,toWhom,something)) (The handout version does not work. The revised version does work.)
Join our real-time social learning platform and learn together with your friends!