Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions docs/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NameError
==========

When one starts writing code, this will be one of the most common exception
he/she will find. This happens when someone tries to access a variable which is
they will find. This happens when someone tries to access a variable which is
not defined.
::

Expand Down Expand Up @@ -45,7 +45,7 @@ is to do addition of Integers and a string.
How to handle exceptions?
=========================

We use `try...except` blocks to handle any exception. The basic syntax looks like
We use `try...except` blocks to handle any exception. The basic syntax looks like:
::

try:
Expand All @@ -58,9 +58,9 @@ We use `try...except` blocks to handle any exception. The basic syntax looks lik

It works in the following way:

- First all lines between `try` and `except` statements.
- If `ExceptionName` happens during execution of the statements then `except` clause statements execute
- If no exception happens then the statements inside `except` clause does not execute.
- First execute statement(s) between `try` and `except` keywords.
- If no exception happens then the statement(s) inside `except` clause does not execute.
- If an exception type, `ExceptionName` happens during execution of the statement(s) then rest of the `try` clause statement(s) skipped and `except` clause statement(s) get executed.
- If the `Exception` is not handled in the `except` block then it goes out of `try` block.

The following examples showcase these scenarios.
Expand Down Expand Up @@ -131,8 +131,7 @@ Using finally for cleanup
==========================

If we want to have some statements which must be executed under all circumstances,
we can use `finally` clause, it will be always executed before finishing `try`
statements.
we can use `finally` clause, it will be always executed just before finishing exception handling.
::

>>> try:
Expand Down