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

try/except... in lecture 10, there is a pice of code which is supposed to be a try/except, and is not on the handout. I copied it here http://dpaste.com/661547/ it is right as far as I know although I have trouble seeing it on the video. Anyway, it doesn't work. It should print the line 'Whoops' but in fact it has a top level error, "TypeError: exceptions must be old-style classes or derived from BaseException, not str" But... it seems to work for him. (I have version 2.7). Not sure what this means or what happened. Anyone else come across this?

OpenStudy (anonymous):

I thing they use an older python version in the video. It should go something like this, I guess: http://dpaste.com/661568/

OpenStudy (anonymous):

They are using 2.4 if i remember correctly and a quick google shows Python stopped the use of strings in raise in version 2.6.

OpenStudy (anonymous):

Cool thanks for the code but it still doesn't work for me... Now it gets instead: NameError: name 'GetGradesError' is not defined if I don't put the class thingie or TypeError: __init__() takes exactly 2 arguments (1 given) if I do. I'm still not terribly familar with classes so I am having trouble knowing what is wrong...

OpenStudy (anonymous):

Okay I got duikboot's code working by changing the raise line to: raise GetGradesError(Exception) thankyou :) I am learning lol.

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!