try:
f =open('myfile.txt')
s = f.readline()
i =int(s.strip()) exceptOSErroras err: print("OS error: {0}".format(err)) exceptValueError: print("Could not convert data to an integer.") except: print("Unexpected error:",sys.exc_info()[0]) raise
class TransitionError(Error): """Raised when an operation attempts a state transition that's not
allowed.
Attributes:
previous -- state at beginning of transition
next -- attempted new state
message -- explanation of why the specific transition is not allowed
"""
def__init__(self, previous, next, message): self.previous= previous self.next= next self.message= message