-Every error message you get in python comes from a built-in class called 'Exception'.
This is important for making your own customized error messages, because in order for those customized messages to work like any other error message, you must make a new subclass of Exception.
-The command 'raise'.
raise is needed for when you want to call a class. If I wanted to call a subclass Customized_error that I made to display my customized error message, I would write the following line in my code:
raise Customized_error("customized error message")
-The commands 'try' and 'except'.
'try' is used for when you want to run a function to see if an error is caused, but not return what the function is supposed to return. 'except' is to be written after try, then followed by the name of an error class or subclass. If that error class or subclass is reached during the call of the function, the line acts very similar to an if statement that returns True, and the program then decides to run the code that is written within the indent of this 'except' line.
This was basically everything I needed to learn in order to finish the exercise. Other than that, my new time slot on Monday-Wednesday mornings is working out much nicer for me, but I've lately been giving more attention to my other courses. This will probably change I hope. Yes.
No comments:
Post a Comment