
LBYL vs EAFP: Preventing or Handling Errors in Python
I completed the intermediate-level tutorial “LBYL vs EAFP: Preventing or Handling Errors in Python” taught by Leodanis Pozo Pamos at Real Python. In this tutorial, I learned about: o Errors and Exceptional Situations: Preventing or Handling Them? o The “Look Before You Leap” (LBYL) Style o The “Easier to Ask Forgiveness Than Permission” (EAFP) Style o The Pythonic Way to Go: LBYL or EAFP? o The LBYL and EAFP Coding Styles in Python • Avoiding Unnecessary Check Repetition • Improving Readability and Clarity • Avoiding Race Conditions • Improving Your Code’s Performance o Common Gotchas With LBYL and EAFP o EAFP vs LBYL With Examples • Dealing With Too Many Errors or Exceptional Situations • Checking for Objects’ Type and Attributes • Working With Files and Directories You can find this tutorial at https://realpython.com/python-lbyl-vs-eafp/