Beginning Programming with Python For Dummies by John Paul Mueller

Beginning Programming with Python For Dummies by John Paul Mueller

Author:John Paul Mueller [Mueller, John Paul]
Language: eng
Format: epub, pdf
ISBN: 9781118891476
Published: 2014-08-22T08:24:36+00:00


print("This code will never execute.")

In this example, the code raises a ValueError exception. The except clause executes as normal when this happens. The call to sys.exit() means that the application exits after the exception is handled. Perhaps the application can’t recover in this particular instance, but the application normally ends, which is why the final print() function call won’t ever execute.

The finally clause code always executes. It doesn’t matter whether the exception happens or not. The code you place in this block needs to be common code that you always want to execute. For example, when working with a file, you place the code to close the file into this block to ensure that the data isn’t damaged by remaining in memory rather than going to disk.



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.