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

The professor made a mistake in lecture 10: at the end of the lecture, he's introducing the use of exceptions, and illustrates it with the getGrades function. Here's his explaination: "And if I go ahead and run this -- now it's going to say woops, at me. What happened? I'm down here and try, I'm trying do get grades, which is a call to that function, which is not bound in my computer. That says it's in here. It's in this tri-block. It raised an exception, but it wasn't and I O error. So it passes it back, past this exception, up to this level, which gets to that exception."

OpenStudy (maitre_kaio):

Sorry I was limited by the size of questions :) Maybe I ujst didn't understand what he was trying to explain, but I think he's mistaken. So I think this is what really happened : 1. The program calls the getGrades function 2. Inside getGrades, fopen can't find the file named grades.txt, so fopen raises an IOError 3. Because fopen is in a try block, the except IOError blocked is interpreted. The IOError is replaced by a GetGradesError. This error bubbles up to the caller, the main program. 4. In the main program, GetGradesError is catched and the except block prints 'whoops'

OpenStudy (anonymous):

i think you got it and i think he misspoke. http://pastebin.com/BCHLQz9y

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!
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!