Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 481 Bytes

File metadata and controls

9 lines (5 loc) · 481 Bytes

Errors in Python

In this section we'll learn about errors and exceptions in Python. We can use them for flow control by following the "ask for forgiveness rather than permission" part of the Python ethos.

Doing so means: try to do something, and if an error happens, handle it.

The alternative would be to check if something can be done first, and then only do it if it can be.

Asking for forgiveness (i.e. catching the errors) is usually simpler and results in simpler code.