Python for .NET Developers 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 is quite similar to C#. We have the exception throwing type of behavior when we say try, do the thing
0:10 instead of catch we say except and we don't have parentheses but, pretty much other than that it's more or less the same.
0:17 The one thing you need to keep in mind also applying Python is this goes from most specific to most general. It goes through and says
0:25 Does the error derive from the thing you see in the except clause? Like, the exception I got, does it derive from BrokenPipeError?
0:32 If it does, run in that bit. If it's an ArithmeticError something deriving from that go in there, and so on. So, just like C#, has to be most specific
0:41 to most general or it's going to get caught too early.


Talk Python's Mastodon Michael Kennedy's Mastodon