Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Due to its power, simplicity, and complete object model, Python has become the scripting language of choice for many large organizations, including Google, Yahoo, and IBM. In Python 3 Essential Training, Bill Weinman demonstrates how to use Python 3 to create well-designed scripts and maintain existing projects. This course covers the basics of the language syntax and usage, as well as advanced features such as objects, generators, and exceptions. Example projects include a normalized database interface and a complete working CRUD application. Exercise files accompany the course.
Exceptions are Python's key method for handling errors. Whenever you see one of Python's little error messages, like you've written some script and you run it for the first time and it dumps you out with stack trace and an error message, those error messages are simply uncaught exceptions. You can catch exceptions in Python using try and except. For example, if you're opening a file and the file name is wrong or you don't have permissions to open the file or something like that, Python will raise an IO Error exception.
You can catch the exception like this, using try and except. Then you can even capture Python's error message, print it, and either continue with your execution or give a user some intelligible error message or whatever exactly it is that you want to do with the error. And then you can use else for conditions where you don't get the error at all, and it just works the way that you expect it to. Of course, you can also raise your own exceptions with the raise statement. You have access to this entire exception handling process. It's built into Python for your own error conditions in the modules, objects, and functions that you write yourself.
So let's go ahead and take a look at how Python uses exceptions for its error reporting.
Find answers to the most frequently asked questions about Python 3 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.