An exception is a Python object that indicates a special event (most often an error) has occurred.
raise ValueError, "Invalid hour value: %d" % hour
The keyword raise is followed by the name of the exception, a comma and a value that the exception
object stores as an attribute. When Python executes a raise statement, an exception is
raised; if the exception is not caught, Python prints an error message that contains the name
of the exception and the exception’s attribute value, as shown in Fig. 7.8.
object stores as an attribute. When Python executes a raise statement, an exception is
raised; if the exception is not caught, Python prints an error message that contains the name
of the exception and the exception’s attribute value, as shown in Fig. 7.8.
No comments:
Post a Comment