CSC148H1 Lecture 9: Exceptions and Unit-tests

48 views8 pages
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

References: code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter/index. shtml. Stacks and sacks can have different implementations: use python lists vs. dictionaries, so it doesn"t make sense to have implementation in a super class. Consider this code that has a lot of errors: If we run it, python never prints the message we got through because of the first zero. If there is any exception evoked, the except block notices it, prints a message, and continues to run through the code. When this code is run, we get to the message we got through it! . It prints the message ooooops! , the type of error, and the message at the end of the code that it didn"t print originally. Exception is too broad -> looks for every single possible exception: add clause -> tells you what kind of exception to look for. Notice how only the first error is displayed -> only notices first error.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers