• Home
  • Raw
  • Download

Lines Matching refs:clause

98 * First, the *try clause* (the statement(s) between the :keyword:`try` and
101 * If no exception occurs, the *except clause* is skipped and execution of the
104 * If an exception occurs during execution of the :keyword:`try` clause, the rest of the
105 clause is skipped. Then, if its type matches the exception named after the
106 :keyword:`except` keyword, the *except clause* is executed, and then execution
110 clause*, it is passed on to outer :keyword:`try` statements; if no handler is
114 A :keyword:`try` statement may have more than one *except clause*, to specify
116 Handlers only handle exceptions that occur in the corresponding *try clause*,
117 not in other handlers of the same :keyword:`!try` statement. An *except clause*
123 A class in an :keyword:`except` clause is compatible with an exception if it is
125 *except clause* listing a derived class is not compatible with a base class).
148 would have printed B, B, B --- the first matching *except clause* is triggered.
169 Alternatively the last except clause may omit the exception name(s), however the exception
173 clause*, which, when present, must follow all *except clauses*. It is useful
174 for code that must be executed if the *try clause* does not raise an exception.
186 The use of the :keyword:`!else` clause is better than adding additional code to
187 the :keyword:`try` clause because it avoids accidentally catching an exception
195 The *except clause* may specify a variable after the exception name. The
223 *try clause*, but also if they occur inside functions that are called (even
224 indirectly) in the *try clause*. For example::
347 The :keyword:`try` statement has another optional clause which is intended to
361 If a :keyword:`finally` clause is present, the :keyword:`!finally`
362 clause will execute as the last task before the :keyword:`try`
363 statement completes. The :keyword:`!finally` clause runs whether or
368 clause, the exception may be handled by an :keyword:`except`
369 clause. If the exception is not handled by an :keyword:`!except`
370 clause, the exception is re-raised after the :keyword:`!finally`
371 clause has been executed.
374 or :keyword:`!else` clause. Again, the exception is re-raised after
375 the :keyword:`!finally` clause has been executed.
377 * If the :keyword:`!finally` clause executes a :keyword:`break`,
383 :keyword:`!finally` clause will execute just prior to the
387 * If a :keyword:`!finally` clause includes a :keyword:`!return`
389 :keyword:`!finally` clause's :keyword:`!return` statement, not the
390 value from the :keyword:`!try` clause's :keyword:`!return`
414 ... print("executing finally clause")
418 executing finally clause
421 executing finally clause
423 executing finally clause
429 As you can see, the :keyword:`finally` clause is executed in any event. The
431 :keyword:`except` clause and therefore re-raised after the :keyword:`!finally`
432 clause has been executed.
434 In real world applications, the :keyword:`finally` clause is useful for