Saturday, February 1, 2014

Week 3 - Exceptions

Unfortunately I underwent a surgery this week and was unable to attend the entire week. However, that didn't stop me from reading through the slides and pages on exceptions...
The concept of "catching" errors and dealing with them is something I thought of last semester in CSC108 where I would think of all the possible cases for a function. I would create a function that would require a certain argument, but I would design the function so that the argument must have a special case to it (ie. a list with n length that must have the int 3..a special case like that.), I would then make the function return a string stating that the argument isn't "correct" (ie. "This list doesn't have the int 3"). I would think of things like this and thought why there isn't a built in way of doing this with python.

Luckily there was a built in way to catch these "mistakes" through the use of user defined exceptions. The concept is very similar to what I had in mind originally except its a more "official" way of doing it. E2 was assigned to test your abilities with using and understanding exceptions, and fortunately I was able to complete the exercise with little struggle...I'm sure everyone else in the course did too, but its just that I feel a lot more rewarded when I essentially learned the concept of exceptions on my own.

No comments:

Post a Comment