WRITELOOP

PYTHON EXCEPTION BEST PRACTICES

2021 April 16
  • Treat only specific exceptions, not general ones.

  • Instead of:

try:
   anything()
except CustomError:
   pass

when you need to ignore the exception, do instead:

with contextlib.supress(CustomError):
    anything()
NOTE: The original content(s) that inspired this one can be found at:
https://www.youtube.com/watch?v=p4jWEC7vuKI
All copyright and intellectual property of each one belongs to its' original author.