finally

Used within a try control structure to contain statements that are execute whether or not there was an error.

# Metadata

Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

finally

# Examples

finally

# Description

Use the finally keyword to designate one or more statements that are to be execute within a try control structure.

The finally keyword appears on a line by itself, and is followed by a list of statements. The statements in the finally section are execute whether or not there was an error while execute the try control structure.

The finally section is always execute even if the try control structure contains an exit or pass statement, so it can be used for final cleanup actions such as deleting variables.

The finally section is optional in a try control structure.

# Tags

# See

- **keyword:** else - **glossary:** keyword, statement, variable, error, execute, control structure - **control structure:** pass, exit, try