Well apparently a whole week has gone by yet again, which means it's time for me to talk about my adventures in CSC148!!!
So I've just finished Exercise 2, and I'd like to say that it wasn't bad at all! The only difficulty exercise 2 posed was being aware of the new syntax and using it correctly. The biggest "trick" to the whole exercise was knowing that E2Error was a superclass of E2OddError. That said, if an except block had:
try:
f(x)
except E2Error:
return 'E2Error, but could be an E2OddError'
return 'no error at all'
Now if f(x) raises an E2Error exception or E2OddError exception (since E2OddError is a subclass of E2Error), then it will return :
'E2Error, but could be an E2OddError'In the python shell:
>>>reporter(raiser, 6) 'E2Error, but could be an E2OddError'
Here I use the reporter function used in the exercise. Reporter gives an E2OddError if x is even, and gives an E2Error
if x is the string 'Go sue me!'.
That was the most challenging part of the exercise, although hopefully not too challenging because it was discussed in class.