Page 223 - Beginning Programming with Pyth - John Paul Mueller
P. 223

unlikely to want to continue using the application at this point.
2. Click Run Cell.
Python asks the user to input a whole number.
3. Type Hello and press Enter.
The application displays an error message and asks whether you want to try again.
4. Type Y and press Enter.
The application asks you to input a whole number again, as shown
in Figure 10-9.
5. Type 5.5 and press Enter.
The application again displays the error message and asks whether you want to try again.
6. Choose Kernel ⇒ Interrupt to interrupt the application, type Y, and then press Enter.
The application ends, as shown in Figure 10-10. Notice that the message is the one from the inner exception. The application never gets to the outer exception because the inner exception handler provides generic exception handling.
7. Click Run Cell.
Python asks the user to input a whole number.
8. Choose Kernel ⇒ Interrupt to interrupt the application, type 5.5, and then press Enter.
The application ends, as shown in Figure 10-11. Notice that the message is the one from the outer exception. In Steps 6 and 8, the user ends the application by pressing an interrupt key. However, the application uses two different exception handlers to address the problem.
   


















































































   221   222   223   224   225