Python Power!: The Comprehensive Guide by Matt Telles

Python Power!: The Comprehensive Guide by Matt Telles

Author:Matt Telles
Language: eng
Format: epub, pdf
Publisher: Course Technology PTR
Published: 2018-10-02T16:00:00+00:00


Now, when we run this script in the interpreter, we can either generate an error or get through the code properly. Let’s look at both cases:

Enter a value: 10 We got some valid input! All went well, x = 10 >>> Enter a value: 0 We got some valid input! You can't divide by ZERO!

When we process a block of potential exception generating code properly, it is important to care about the “happy path” case, as well as all of the error cases. The else clause is an important weapon in creating exception free code. Note, however, that code within an else clause can generate exceptions and that those exceptions will not be caught by the try block above them. Only place code within the else block that you know to be safe, or encase it in its own try block for safety.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.