Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

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.