Python for the .NET developer Transcripts
Chapter: The Python Language
Lecture: Concept: Python error handling

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Error handling in Python
0:01 is quite similar to C#.
0:03 We have the exception throwing type of behavior
0:07 when we say try, do the thing
0:09 instead of catch we say except
0:11 and we don't have parentheses
0:12 but, pretty much other than that
0:13 it's more or less the same.
0:16 The one thing you need to keep in mind
0:17 also applying Python is
0:19 this goes from most specific to most general.
0:23 It goes through and says
0:24 Does the error derive from the thing you see
0:27 in the except clause?
0:28 Like, the exception I got, does it derive
0:30 from BrokenPipeError?
0:31 If it does, run in that bit.
0:33 If it's an ArithmeticError
0:34 something deriving from that
0:36 go in there, and so on.
0:37 So, just like C#, has to be most specific
0:40 to most general
0:41 or it's going to get caught too early.