- [Instructor] In this and the next several videos,
we're going to be talking about handling exceptions
in Python.
So far, when we've had runtime problems in our code,
we've simply seen tracebacks appear either in Ipython
or at the command line when we were running a Python script.
However it is possible to write code that can look
at problems that occur and then deal with those problems.
Now in the context of file processing,
there happen to be a number of potential exceptions
that can occur.
So, for example, if I try to open up a file
that does not exist, so that I can read from that file,
I'll wind up with a file not found error,
or if I try to open a file for reading
that's in a folder that I don't have access to,
or I try to write a file into a folder
that I don't have access to,
I'll get a permissions error.
And if I try to write to a file object
that's already been closed,
I'll get a value error.
So what we wanna do over the next several videos
is talk about how we can write code
that's capable of dealing with exceptions.
And we'll start by revisiting the concept
of an exception in the first place,
and then show you the code that can be used to deal
with problems as they occur.