0:00
/
0:00
Transcript
0:05
SPEAKER 1
Hello, and welcome back to Python 101. My name is Michael Driscoll, and today I will be teaching you about exception handling in Python. What to do when things go wrong. In this tutorial, we will learn about why you might need exception handling. So you might need exception handling when you accept user input.
0:24
You never know what your users will do. They might type characters in that you don't expect. For example, you might have a dialogue that asks for integers and your user might completely ignore you and start typing numbers in or special characters. Another time you might need exception handling is when you accept files from users.
0:43
So, you know, you might have a client and you say, I accept XML, but they give you a JSON file. You just need to find a way to raise an exception or to handle that gracefully and let the user know that they gave you the wrong file type.

What do you do when something goes wrong in your Python program?

You need to catch that exception and handle it.

In this tutorial, you will learn the following:

  • Common exceptions

  • Handling exceptions

  • Raising exceptions

  • Examining exception objects

  • Using the `finally` statement

  • Using the `else` statement

Want to learn more, buy my Python 101 book:

Gumroad (eBook) - https://gumroad.com/l/pypy101

Amazon (Paperback / Kindle) - https://amzn.to/2Zo1ARG

Discussion about this video

User's avatar
Tomer Ben Arye's avatar

There is always something I'm learning from you Mike! keep those coming!

Expand full comment
Mike Driscoll's avatar

Thanks! I'm glad you enjoyed the video!

Expand full comment
0:43
So, you know, you might have a client and you say, I accept XML, but they give you a JSON file. You just need to find a way to raise an exception or to handle that gracefully and let the user know that they gave you the wrong file type.