Changes

Jump to: navigation, search

OPS435 Python Lab 5

1 byte added, 11:37, 5 September 2017
PART 1 - Handling Errors
raise
</source>When catching multiple exceptions, make certain to catch the <u>lowest</u> ones contained in the exception-hierarchy first. For example, if you put 'Exception' first, both 'OSError' and 'FileNotFoundError', would never get caught.<br><br>'''TIP:''' In python it's usually best to 'try:' and 'except:' code rather than to try and determine everything that could go wrong with logic and if statements. For example, instead of checking to see if a file exists and we have read permissions, it can be better to just try and read the file and fail and catch any errors with 'OSError'.
 
=== Create a Python Script Which Handles Errors ===
13,420
edits

Navigation menu