Page 132 -
P. 132
more errors
What about other errors?
It is true that both approaches work, but let’s consider what happens when
other errors surface.
Ummm...I’m not totally
OK, guys. How does you sure, to be honest...
code react when the
data file is deleted? I guess that’ll produce
another exception, but
what happens in my code
is anyone’s guess.
Handling missing files
Frank’s posed an interesting question and, sure
enough, the problem caused by the removal of
the data file makes life more complex for Jill and
Joe. When the data file is missing, both versions of Rename the data file, then
the program crash with an IOError. run both versions of your
program again to confirm
Do this! that they do indeed raise an
IOError and generate a
traceback.
96 Chapter 3