File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2996,9 +2996,9 @@ \section{Handling Exceptions \label{handling}}
29962996\end {verbatim }
29972997
29982998The \keyword {try} \ldots \ \keyword {except} statement has an optional
2999- \emph {else clause }, which must follow all except clauses. It is
3000- useful to place code that must be executed if the try clause does not
3001- raise an exception. For example:
2999+ \emph {else clause }, which, when present, must follow all except
3000+ clauses. It is useful for code that must be executed if the try
3001+ clause does not raise an exception. For example:
30023002
30033003\begin {verbatim }
30043004for arg in sys.argv[1:]:
@@ -3011,6 +3011,11 @@ \section{Handling Exceptions \label{handling}}
30113011 f.close()
30123012\end {verbatim }
30133013
3014+ The use of the \keyword {else} clause is better than adding additional
3015+ code to the \keyword {try} clause because it avoids accidentally
3016+ catching an exception that wasn't raised by the code being protected
3017+ by the \keyword {try} \ldots \ \keyword {except} statement.
3018+
30143019
30153020When an exception occurs, it may have an associated value, also known as
30163021the exceptions's \emph {argument }.
You can’t perform that action at this time.
0 commit comments