diff --git a/your-first-python-program.html b/your-first-python-program.html index 16cc3c6..731bef3 100755 --- a/your-first-python-program.html +++ b/your-first-python-program.html @@ -264,7 +264,7 @@ SyntaxError: non-keyword arg after keyword arg
☞Unlike Java, Python functions don’t declare which exceptions they might raise. It’s up to you to determine what possible exceptions you need to catch. -
An exception doesn’t need result in a complete program crash, though. Exceptions can be handled. Sometimes an exception is really because you have a bug in your code (like accessing a variable that doesn’t exist), but sometimes an exception is something you can anticipate. If you’re opening a file, it might not exist. If you’re importing a module, it might not be installed. If you’re connecting to a database, it might be unavailable, or you might not have the correct security credentials to access it. If you know a line of code may raise an exception, you should handle the exception using a try...except block.
+
An exception doesn’t need to result in a complete program crash, though. Exceptions can be handled. Sometimes an exception is really because you have a bug in your code (like accessing a variable that doesn’t exist), but sometimes an exception is something you can anticipate. If you’re opening a file, it might not exist. If you’re importing a module, it might not be installed. If you’re connecting to a database, it might be unavailable, or you might not have the correct security credentials to access it. If you know a line of code may raise an exception, you should handle the exception using a try...except block.
☞Python uses
try...exceptblocks to handle exceptions, and theraisestatement to generate them. Java and C++ usetry...catchblocks to handle exceptions, and thethrowstatement to generate them.