Loading video player…

Handling or Preventing Errors in Python: LBYL vs EAFP (Overview)

Dealing with errors and exceptional situations is a common requirement in programming. You can either prevent errors before they happen or handle errors after they’ve happened. In general, you’ll have two coding styles matching these strategies: look before you leap (LBYL), and easier to ask forgiveness than permission (EAFP), respectively. In this video course, you’ll dive into the questions and considerations surrounding LBYL vs EAFP in Python.

By learning about Python’s LBYL and EAFP coding styles, you’ll be able to decide which strategy and coding style to use when you’re dealing with errors in your code.

In this video course, you’ll learn how to:

  • Use the LBYL and EAFP styles in your Python code
  • Understand the pros and cons of LBYL vs EAFP
  • Decide when to use either LBYL or EAFP
Download

Course Slides (.pdf)

4.8 MB
Download

Sample Code (.zip)

3.0 KB

00:00 Handling or Preventing Errors in Python: Look Before You Leap vs Easier to Ask Forgiveness Than Permission. My name’s Joseph and I’ll be your instructor for this video course.

00:10 This course is about errors in exceptional situations and how you can either prevent or handle them. Understanding different programming styles is essential in your journey as a Python developer.

00:20 No two situations will be identical and the best developers make sure they have a variety of techniques that they’re ready to tackle whatever difficulties arise.

00:30 As a programmer, I’m sure you’re familiar with errors. Whether you’re a beginner or an expert, you’ll find that errors are always with you. In this course, we’ll talk about two of the major strategies for handling errors in Python.

00:42 The first is Look Before You Leap, also called LBYL. This style seeks to prevent errors before they happen and typically uses conditional logic. The second is it’s Easier to Ask Forgiveness Than Permission, also called EAFP.

00:57 This style handles errors after they occur and uses Python-specific try except syntax.

01:04 By the end of this course, you’ll learn the importance of errors and error handling, how to write code in either an EAFP or an LBYL style, the advantages and disadvantages of each style, as well as how to pick the right style for any situation.

01:20 So if you’re ready to take your understanding of errors to the next level, I’ll see you in the following lesson.

Become a Member to join the conversation.