First page Back Continue Last page Overview Graphics

except with Multiple Exceptions

An except clause may name more than one exception in a tuple of error names, as we see in the following example:

try:

f = open('integers.txt')

s = f.readline()

i = int(s.strip())

except (IOError, ValueError):

print("An I/O error or a ValueError occurred")

except:

print("An unexpected error occurred")

raise