Skip to main content

Try Block AST Python Object

The TryBlock object matches a Python function, module or object call.

The astType value for this node is trystatement.

Code Pattern

This AST element captures the following code.


try:
...
except ExceptionName:
...
finally:
...

Attributes

  • content (type AstElement): the content of the try block (e.g. the statements in the block)
  • exceptClauses (array or ExceptClause): a list of exception in the except clause
  • finallyClause (type FinallyClause): the finally clause

Examples of rules